public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-9463] c++: attribute on dtor in template [PR108795]
Date: Fri, 21 Apr 2023 20:48:09 +0000 (GMT)	[thread overview]
Message-ID: <20230421204809.A208E3858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:1c1a9a0b60a9a182bcff79084e5ac367a6329bc2

commit r12-9463-g1c1a9a0b60a9a182bcff79084e5ac367a6329bc2
Author: Jason Merrill <jason@redhat.com>
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 <typename T> void g (T x)
+{
+  struct C
+  {
+    __attribute__((transaction_safe)) ~C();
+  };
+  C::~C();			// { dg-error "" }
+}
+void f ()
+{
+  g (5);
+}

                 reply	other threads:[~2023-04-21 20:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230421204809.A208E3858D20@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).