aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-03-21 15:15:27 -0400
committerJason Merrill <jason@redhat.com>2023-03-22 12:04:29 -0400
commit426cab4e3b46abaeae0813042b5addc789e3b2be (patch)
treee991d6954901d5518fa51c98b738ef7fd40e94a4 /gcc
parentd3a6f174543816600b1f472997d492088e4e396a (diff)
downloadgcc-426cab4e3b46abaeae0813042b5addc789e3b2be.zip
gcc-426cab4e3b46abaeae0813042b5addc789e3b2be.tar.gz
gcc-426cab4e3b46abaeae0813042b5addc789e3b2be.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/semantics.cc1
-rw-r--r--gcc/testsuite/g++.dg/ext/attr-tsafe1.C14
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 87c2e8a..99a76e3 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -4238,6 +4238,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 0000000..20c319f
--- /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);
+}