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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 58A443857801 for ; Thu, 3 Jun 2021 20:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58A443857801 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-4OqK6L1LMBqp7SMvdcviKQ-1; Thu, 03 Jun 2021 16:31:58 -0400 X-MC-Unique: 4OqK6L1LMBqp7SMvdcviKQ-1 Received: by mail-qk1-f199.google.com with SMTP id a193-20020a3766ca0000b02903a9be00d619so5150383qkc.12 for ; Thu, 03 Jun 2021 13:31:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BiVmcVIbb5HNHzCqX0HCoUPzxzGBShpuGGNW90kCapU=; b=Y7fMdi+XMTZ/X8ygCXIolcw0Hp0cxoGA1ZZZX/K3y45JXOEbMIJU173fs8n7ovymxt HEm5Y2w/vuUK0IALtbTPdEpbRRingl+aILJr5JfpjICxcF9SciWjhkaY8Ie8YNbmTEGG qGhrTSC5DMR39rOUCjpg8GnGEVgM8oLJpKoHIC5Dg1zUHlkpz9MsfPMAMeBsTTjpiV6o FEZ0u3NbE8bAq0KMbSl4TNV20J7u9yYJjEzs+l7Dee7rj+Ca97FIYVobI/dCm24Dogvz LDQE/oh4BvnvS8+Xlli7y8oKuvJ+xzMNvAK7Tf0gXrp3nvWyKQ5JjcqqwDQ+plAQZb5u VnEg== X-Gm-Message-State: AOAM5337dvR05RHmFXiJcONc1zkJzWlk86v72cWIhURrTm1Pc+Q+pvz9 ND8kkG8K1GHUHnBSr+J7UN+7qJLUt98eLbakY/9vm+nOJN+aRV2g1TccamWEaqb7D3dQhPH7EBQ GXmMUvlfxWLW5wpjdc6J58K6be9EXJGG/eIluMSBeD5Ugrp2VaKZtD3pxyuL2vwgy0Q== X-Received: by 2002:ae9:ef55:: with SMTP id d82mr1053158qkg.3.1622752316977; Thu, 03 Jun 2021 13:31:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKVwJGcOHQk6T/2Uje2V+IdOhmdqPO5n/SlgjJLQ/jQ1nUMKn6G1f/THlQMltrzIPfNEFjWA== X-Received: by 2002:ae9:ef55:: with SMTP id d82mr1053125qkg.3.1622752316562; Thu, 03 Jun 2021 13:31:56 -0700 (PDT) Received: from [192.168.1.148] ([130.44.159.43]) by smtp.gmail.com with ESMTPSA id a68sm2567498qkd.51.2021.06.03.13.31.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 13:31:55 -0700 (PDT) Subject: Re: [PATCH] c++: Fix up attribute handling in methods in templates [PR100872] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20210603090019.GC7746@tucnak> From: Jason Merrill Message-ID: <574c87fc-2c13-985c-25b7-1f8e502c9f90@redhat.com> Date: Thu, 3 Jun 2021 16:31:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210603090019.GC7746@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 03 Jun 2021 20:32:01 -0000 On 6/3/21 5:00 AM, Jakub Jelinek wrote: > Hi! > > The following testcase FAILs because a dependent (late) attribute is never > tsubsted. While the testcase is OpenMP, I think it is a generic C++ FE problem > that could affect any other dependent attribute. > > apply_late_template_attributes documents that it relies on > /* save_template_attributes puts the dependent attributes at the beginning of > the list; find the non-dependent ones. */ > The "operator binding" attributes that are sometimes added are added to the > head of DECL_ATTRIBUTES list though and because it doesn't have > ATTR_IS_DEPENDENT set it violates this requirement. > > The following patch fixes it by adding that attribute after all > ATTR_IS_DEPENDENT attributes. I'm not 100% sure if DECL_ATTRIBUTES can't be > shared by multiple functions (e.g. the cdtor clones), but the code uses > later remove_attribute which could break that too. In any case it passed > bootstrap/regtest on x86_64-linux and i686-linux. OK. > Other option would be to copy_list the ATTR_IS_DEPENDENT portion of the > DECL_ATTRIBUTES list if we need to do this, that would be the same as this > patch but replace that *ap = op_attr; at the end with > *ap = NULL_TREE; > DECL_ATTRIBUTES (cfn) = chainon (copy_list (DECL_ATTRIBUTES (cfn)), > op_attr); > Or perhaps set ATTR_IS_DEPENDENT on the "operator bindings" attribute, > though it would need to be studied what would it try to do with the > attribute during tsubst. > 2021-06-03 Jakub Jelinek > > PR c++/100872 > * name-lookup.c (maybe_save_operator_binding): Add op_attr after all > ATTR_IS_DEPENDENT attributes in the DECL_ATTRIBUTES list rather than > to the start. > > * g++.dg/gomp/declare-simd-8.C: New test. > > --- gcc/cp/name-lookup.c.jj 2021-05-11 09:06:24.281997782 +0200 > +++ gcc/cp/name-lookup.c 2021-06-02 15:50:52.042521824 +0200 > @@ -9136,9 +9136,12 @@ maybe_save_operator_binding (tree e) > tree op_attr = lookup_attribute (op_bind_attrname, attributes); > if (!op_attr) > { > + tree *ap = &DECL_ATTRIBUTES (cfn); > + while (*ap && ATTR_IS_DEPENDENT (*ap)) > + ap = &TREE_CHAIN (*ap); > op_attr = tree_cons (get_identifier (op_bind_attrname), > - NULL_TREE, attributes); > - DECL_ATTRIBUTES (cfn) = op_attr; > + NULL_TREE, *ap); > + *ap = op_attr; > } > > tree op_bind = purpose_member (fnname, TREE_VALUE (op_attr)); > --- gcc/testsuite/g++.dg/gomp/declare-simd-8.C.jj 2021-06-02 16:02:32.792681922 +0200 > +++ gcc/testsuite/g++.dg/gomp/declare-simd-8.C 2021-06-02 16:02:09.849004442 +0200 > @@ -0,0 +1,15 @@ > +// PR c++/100872 > + > +template > +struct S { > + #pragma omp declare simd aligned(a : N * 2) aligned(b) linear(ref(b): N) > + float foo (float *a, T *&b) { return *a + *b; } > +}; > + > +S<16, float> s; > + > +float > +bar (float *a, float *p) > +{ > + return s.foo (a, p); > +} > > Jakub >