From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 8C2BE3857814 for ; Thu, 16 Sep 2021 15:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C2BE3857814 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-kNhuvATaOLSIAtM6J4B4tg-1; Thu, 16 Sep 2021 11:19:29 -0400 X-MC-Unique: kNhuvATaOLSIAtM6J4B4tg-1 Received: by mail-qv1-f70.google.com with SMTP id ci14-20020a056214054e00b0037a75ff56f9so55906305qvb.23 for ; Thu, 16 Sep 2021 08:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=nMoRNNOUcfNZq1ghwrKZzVHI44KXVNr2Pyj/anxYF/E=; b=O5btlcXD5U70RnHCnTzPfa2/eKnediNOUjwgr4WZUgaRUjvG+PV1zDeowpb577/oZd JhQ3TGZXr5VeTtRReureMX7Ezy+c7oGGnnDA2vVdaLi94aipra3WhKq7N2RZDjOakw/G D2vK+szx7LZnSlFH65owtLpCGZ03kmkHbXDZDV047JG2eFfdz7mf+h+9R3jXzEe4dsMl GGEhKnF6E1r5+4sR5CxqC66JtGvT+fw00LF16RIipQ6a8Uedo7rF/lmNuzwXDqWMaUE0 xmoSrdh0MPXl+ndm7pfsjl0F8vtidXhJFpIW37IrlF/qtN5BYRaDZRDhd9fXiIKsLHky wXQQ== X-Gm-Message-State: AOAM532eJETAWiLR8mqgPnCaTo4GrAegR8jkOfri2ZUfU+w4a/e+4fGu SHHLywizFPLIqPH/qabUk9C8+pt6bNr5q7WbVSKWc/zfvkgTdbsHXTAoq7kKVc6tjji3C6JJPTU A47NcG2OqMJRMFFUahA== X-Received: by 2002:ac8:4b64:: with SMTP id g4mr5479085qts.263.1631805568835; Thu, 16 Sep 2021 08:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsLOkSrSJKX71gGJs1t1VY6HmcsrGC0smni2jNStq4hKaZbV5yArIWBPO+C6QBpbeYFCiMVA== X-Received: by 2002:ac8:4b64:: with SMTP id g4mr5479054qts.263.1631805568496; Thu, 16 Sep 2021 08:19:28 -0700 (PDT) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id r139sm965468qke.84.2021.09.16.08.19.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Sep 2021 08:19:27 -0700 (PDT) Message-ID: Date: Thu, 16 Sep 2021 11:19:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH] C++: add type checking for static local vector variable in template To: wangpc , gcc-patches@gcc.gnu.org References: <20210916091153.3035-1-pc.wang@linux.alibaba.com> From: Jason Merrill In-Reply-To: <20210916091153.3035-1-pc.wang@linux.alibaba.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 15:19:32 -0000 On 9/16/21 05:11, wangpc via Gcc-patches wrote: > This patch adds type checking for static local vector variable in > C++ template, both AArch64 SVE and RISCV RVV are of sizeless type > and they all have this issue. > > 2021-08-06 wangpc > > gcc/cp/ChangeLog > > * decl.c (cp_finish_decl): Add type checking. > > gcc/testsuite/ChangeLog > > * g++.target/aarch64/sve/static-var-in-template.C: New test. > > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c > index 90111e4c786..e3a06ea0858 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -7520,6 +7520,12 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, > && DECL_INITIALIZED_IN_CLASS_P (decl)) > check_static_variable_definition (decl, type); > > + if (VAR_P (decl) > + && DECL_FUNCTION_SCOPE_P (decl) > + && TREE_STATIC (decl)) > + verify_type_context (DECL_SOURCE_LOCATION (decl), > + TCTX_STATIC_STORAGE, type); I was thinking to move the verify_type_context code from start_decl, which handles more cases: > if (is_global_var (decl)) > { > type_context_kind context = (DECL_THREAD_LOCAL_P (decl) > ? TCTX_THREAD_STORAGE > : TCTX_STATIC_STORAGE); > verify_type_context (input_location, context, TREE_TYPE (decl)); > } Jason