diff mbox series

[committed] c-family: Fix ICE on attribute with -fgnu-tm [PR94733]

Message ID 20200423192305.3613471-1-polacek@redhat.com
State New
Headers show
Series [committed] c-family: Fix ICE on attribute with -fgnu-tm [PR94733] | expand

Commit Message

Marek Polacek April 23, 2020, 7:23 p.m. UTC
find_tm_attribute was using TREE_PURPOSE to get the attribute name,
which is breaking now that we preserve the C++11-style attribute
format past decl_attributes.  So use get_attribute_name which can
handle both formats of attributes.

Tested x86_64-pc-linux-gnu, applying to trunk.

	PR c++/94733
	* c-attribs.c (find_tm_attribute): Use get_attribute_name instead of
	TREE_PURPOSE.

	* g++.dg/tm/attrib-5.C: New test.
---
 gcc/c-family/c-attribs.c           | 2 +-
 gcc/testsuite/g++.dg/tm/attrib-5.C | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/tm/attrib-5.C


base-commit: dcf69ac5448fd6a16137cfe9fe6deadd0ec0243d
diff mbox series

Patch

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 1483b3540dc..ac936d5bbbb 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -3314,7 +3314,7 @@  find_tm_attribute (tree list)
 {
   for (; list ; list = TREE_CHAIN (list))
     {
-      tree name = TREE_PURPOSE (list);
+      tree name = get_attribute_name (list);
       if (tm_attr_to_mask (name) != 0)
 	return name;
     }
diff --git a/gcc/testsuite/g++.dg/tm/attrib-5.C b/gcc/testsuite/g++.dg/tm/attrib-5.C
new file mode 100644
index 00000000000..0b7bc728f06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tm/attrib-5.C
@@ -0,0 +1,5 @@ 
+// PR c++/94733
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+struct [[gnu::may_alias]] pe { };