]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: attribute on dtor in template [PR108795]
authorJason Merrill <jason@redhat.com>
Tue, 21 Mar 2023 19:15:27 +0000 (15:15 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 21 Apr 2023 20:48:01 +0000 (16:48 -0400)
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.

gcc/cp/semantics.cc
gcc/testsuite/g++.dg/ext/attr-tsafe1.C [new file with mode: 0644]

index ae6cf71b4f59d4e93cfae22b8d06123c6390ab5a..ee0db331f34cfbe017552e5cb61694f53cdb9bdb 100644 (file)
@@ -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 (file)
index 0000000..20c319f
--- /dev/null
@@ -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);
+}