From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id A208E3858D20; Fri, 21 Apr 2023 20:48:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A208E3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682110089; bh=IGUB+nPtQMYcmwfWkwgGNcbZC3BrJQvIgDnkJrJESj4=; h=From:To:Subject:Date:From; b=dpuSGwTDLUwsCQjmzeeD/UcvEtJMshBlSZ8J9UGYn01+/4vyzozT83QrasZII11T1 wnAGKYIo/QheeE2X/i3QXuTjWJ6VUvupqDSQBDSHtMpKetnqJxAv7X5owb3Qf70Edl zJi61wU9dfPCimA/SJYddSi/YNbe1t23iDscolTU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9463] c++: attribute on dtor in template [PR108795] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 8caf5805ad76125b84430b8653003f4776489d46 X-Git-Newrev: 1c1a9a0b60a9a182bcff79084e5ac367a6329bc2 Message-Id: <20230421204809.A208E3858D20@sourceware.org> Date: Fri, 21 Apr 2023 20:48:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1c1a9a0b60a9a182bcff79084e5ac367a6329bc2 commit r12-9463-g1c1a9a0b60a9a182bcff79084e5ac367a6329bc2 Author: Jason Merrill Date: Tue Mar 21 15:15:27 2023 -0400 c++: attribute on dtor in template [PR108795] Since r7-2549 we were throwing away the explicit C:: when we found that ~C has an attribute that we treat as making its type dependent. PR c++/108795 gcc/cp/ChangeLog: * semantics.cc (finish_id_expression_1): Check scope before returning id_expression. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-tsafe1.C: New test. Diff: --- gcc/cp/semantics.cc | 1 + gcc/testsuite/g++.dg/ext/attr-tsafe1.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index ae6cf71b4f5..ee0db331f34 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -4152,6 +4152,7 @@ finish_id_expression_1 (tree id_expression, : CP_ID_KIND_UNQUALIFIED))); if (dependent_p + && !scope && DECL_P (decl) && any_dependent_type_attributes_p (DECL_ATTRIBUTES (decl))) /* Dependent type attributes on the decl mean that the TREE_TYPE is diff --git a/gcc/testsuite/g++.dg/ext/attr-tsafe1.C b/gcc/testsuite/g++.dg/ext/attr-tsafe1.C new file mode 100644 index 00000000000..20c319f154d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-tsafe1.C @@ -0,0 +1,14 @@ +// PR c++/108795 + +template void g (T x) +{ + struct C + { + __attribute__((transaction_safe)) ~C(); + }; + C::~C(); // { dg-error "" } +} +void f () +{ + g (5); +}