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 ESMTPS id 41D27385842D for ; Thu, 14 Dec 2023 20:37:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41D27385842D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 41D27385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702586223; cv=none; b=ECIRJfDXKpjBTcyZTVwCQFFH5ShPs6VXs1/BqfbVoLsIYW/tVvoMNr2H2bVzuMUYX/62AayhqSo1BdKwpIHFuJcap5GaGKMWvGG9JlpTUwepCzEtE4SZSYMNWpIEe3L+rlTet0tiQa4eVGhgZkr9jOt6vW7dCodKpRmbNHmOcNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702586223; c=relaxed/simple; bh=MPrKcpLRiW7X9LlnMrdVN1TPPHRLH4WxhCUbjrWItp0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=MC89Nxzlaa9REOehC5E8cdLNiC+2uQMCCNguwTmqvVJ8FGru9O5tvVBGpiPymfigOMNwX6K66osvoIH7xBKp555/BWmIgemdFxFWiB0VY8L6T7gHxBEzs6ow3sDodvF0Fhk9Ey0aah8fa8s57mXg0MIKY6orruDgPdLmj7aNYbE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702586221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3FbDpSJH6HOzOFUeqflgSrRXUUsQ6IEe3c2oSukmsXc=; b=KYNMqN4HkSAzK14nkANvdWTnTOuO/RVIpkfRNNiXjfZz4QzLb+WHAQfyr7DJBstxh0Vcc0 d9CxOA8tA4qyT3XyRgWTpKldgHuzHkYcOPdNSrt/hl8wFXwKGLVj7fw5mj+QdZ4FmhoEEP Aznk+qu3GwP28LEX2VuUG/TRUTbh2bc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-_9K6F3tmPQW5dMv5l5OKJA-1; Thu, 14 Dec 2023 15:37:00 -0500 X-MC-Unique: _9K6F3tmPQW5dMv5l5OKJA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67ade35a3a2so116211136d6.1 for ; Thu, 14 Dec 2023 12:37:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702586220; x=1703191020; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3FbDpSJH6HOzOFUeqflgSrRXUUsQ6IEe3c2oSukmsXc=; b=DvhQiWXZLOQItRmTUWxyWCsThFpVw2sccmWi8NhaB5DFaljQ38ertL7UHM5WlWbHDq RexkD5QS5vc3sGNR0sKcP7nrzkSwfPmAqDhlKJqica9JoAhhOD6TbhGdPDdKU2Wii2Qz 1Q3lTyAisVL84pw0aq3ddkGvgNSlvSj+2pNob4JMvWywUqhL+ntjUGDcWRbKH4PL7uDN WxOvlRMDmPJztQeD+T8QoLesOWKJIDuTC+IhLETRBXjYor2DWhhRNO/vUjVDC6Geu6IH OQYTKIx4FJPoYlR3hkCJF2K55xrIV++lIztun3h1IOPaQOVu65A+xwQrQUeHO0UdnIkT a7qQ== X-Gm-Message-State: AOJu0YySYe+24CC+jiR4WOSZfVabNPM5tFPcGkt6AA11Bgj2MDzvn00k 79BKeZuhVTaTAmPnMW1IPGEQZDJnhkmGMbrpSDT8ggccMZn72i8CYPmQF/ef4QtVPzURzPFBE7l vJQwjj38uncFQJIkrXg== X-Received: by 2002:a05:6214:1313:b0:67e:ab2e:59fb with SMTP id pn19-20020a056214131300b0067eab2e59fbmr16616018qvb.20.1702586219887; Thu, 14 Dec 2023 12:36:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHA3QpgV9Sc0kY0p/3Dj2mnfmDBqLBvBxXtwhvCiHozS84evMKI0dE7I9ggnYiPNl5p7CDaWw== X-Received: by 2002:a05:6214:1313:b0:67e:ab2e:59fb with SMTP id pn19-20020a056214131300b0067eab2e59fbmr16616013qvb.20.1702586219560; Thu, 14 Dec 2023 12:36:59 -0800 (PST) Received: from [192.168.1.146] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id z7-20020a0cd787000000b0067ee768638asm2618863qvi.7.2023.12.14.12.36.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 12:36:59 -0800 (PST) Message-ID: <0ed8c1da-bbcf-4395-8390-06e569ac96aa@redhat.com> Date: Thu, 14 Dec 2023 15:36:58 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: section attribute on templates [PR70435, PR88061] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20231214191725.1941372-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20231214191725.1941372-1-ppalka@redhat.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=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/14/23 14:17, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > -- >8 -- > > The section attribute currently has no effect on templates because the > call to set_decl_section_name only happens at parse time and not also at > instantiation time. This patch fixes this by propagating the section > name from the template to the instantiation. > > PR c++/70435 > PR c++/88061 > > gcc/cp/ChangeLog: > > * pt.cc (tsubst_function_decl): Call set_decl_section_name. > (tsubst_decl) : Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/attr-section1.C: New test. > * g++.dg/ext/attr-section1a.C: New test. > * g++.dg/ext/attr-section2.C: New test. > * g++.dg/ext/attr-section2a.C: New test. > --- > gcc/cp/pt.cc | 4 ++++ > gcc/testsuite/g++.dg/ext/attr-section1.C | 9 +++++++++ > gcc/testsuite/g++.dg/ext/attr-section1a.C | 11 +++++++++++ > gcc/testsuite/g++.dg/ext/attr-section2.C | 9 +++++++++ > gcc/testsuite/g++.dg/ext/attr-section2a.C | 14 ++++++++++++++ > 5 files changed, 47 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/ext/attr-section1.C > create mode 100644 gcc/testsuite/g++.dg/ext/attr-section1a.C > create mode 100644 gcc/testsuite/g++.dg/ext/attr-section2.C > create mode 100644 gcc/testsuite/g++.dg/ext/attr-section2a.C > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 50e6f062c85..8c4174fb902 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -14607,6 +14607,8 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, > = remove_attribute ("visibility", DECL_ATTRIBUTES (r)); > } > determine_visibility (r); > + if (DECL_SECTION_NAME (t)) > + set_decl_section_name (r, t); > if (DECL_DEFAULTED_OUTSIDE_CLASS_P (r) > && !processing_template_decl) > defaulted_late_check (r); > @@ -15423,6 +15425,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain, > = remove_attribute ("visibility", DECL_ATTRIBUTES (r)); > } > determine_visibility (r); > + if (!local_p && DECL_SECTION_NAME (t)) > + set_decl_section_name (r, t); > } > > if (!local_p) > diff --git a/gcc/testsuite/g++.dg/ext/attr-section1.C b/gcc/testsuite/g++.dg/ext/attr-section1.C > new file mode 100644 > index 00000000000..b8ac65baa93 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/attr-section1.C > @@ -0,0 +1,9 @@ > +// PR c++/70435 > +// { dg-do compile { target { c++11 && named_sections } } } > + > +template > +[[gnu::section(".foo")]] void fun() { } > + > +template void fun(); > + > +// { dg-final { scan-assembler {.section[ \t]+.foo} } } > diff --git a/gcc/testsuite/g++.dg/ext/attr-section1a.C b/gcc/testsuite/g++.dg/ext/attr-section1a.C > new file mode 100644 > index 00000000000..be24be2fc95 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/attr-section1a.C > @@ -0,0 +1,11 @@ > +// PR c++/70435 > +// { dg-do compile { target { c++11 && named_sections } } } > + > +template > +struct A { > + [[gnu::section(".foo")]] void fun() { } > +}; > + > +template struct A; > + > +// { dg-final { scan-assembler {.section[ \t]+.foo} } } > diff --git a/gcc/testsuite/g++.dg/ext/attr-section2.C b/gcc/testsuite/g++.dg/ext/attr-section2.C > new file mode 100644 > index 00000000000..a76f43b346f > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/attr-section2.C > @@ -0,0 +1,9 @@ > +// PR c++/88061 > +// { dg-do compile { target { c++14 && named_sections } } } > + > +template > +[[gnu::section(".foo")]] int var = 42; > + > +template int var; > + > +// { dg-final { scan-assembler {.section[ \t]+.foo} } } > diff --git a/gcc/testsuite/g++.dg/ext/attr-section2a.C b/gcc/testsuite/g++.dg/ext/attr-section2a.C > new file mode 100644 > index 00000000000..a0b01cd8d93 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/attr-section2a.C > @@ -0,0 +1,14 @@ > +// PR c++/88061 > +// { dg-do compile { target { c++11 && named_sections } } } > + > +template > +struct A { > + [[gnu::section(".foo")]] static int var; > +}; > + > +template > +int A::var = 42; > + > +template struct A; > + > +// { dg-final { scan-assembler {.section[ \t]+.foo} } }