c-family: Fix ICE on attribute with -fgnu-tm [PR94733]
authorMarek Polacek <polacek@redhat.com>
Thu, 23 Apr 2020 18:38:58 +0000 (14:38 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 23 Apr 2020 19:13:55 +0000 (15:13 -0400)
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.

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/ChangeLog
gcc/c-family/c-attribs.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tm/attrib-5.C [new file with mode: 0644]

index 66f4873c3c26a6f2620a697c0ff241587cd868e2..55e6eb8ae4504ab041858e57f5526f46435c1b22 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/94733
+       * c-attribs.c (find_tm_attribute): Use get_attribute_name instead of
+       TREE_PURPOSE.
+
 2020-04-14  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/85278
index 1483b3540dc58fea16864d061263240db92c5f69..ac936d5bbbb45ec38a9572acb0ef4d4ae8870751 100644 (file)
@@ -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;
     }
index c6ae489c43dcd694803833b42245c3e71356cc4f..b287e12588f2760c4be6c0ed06f53143ddf14693 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/94733
+       * g++.dg/tm/attrib-5.C: New test.
+
 2020-04-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/94724
diff --git a/gcc/testsuite/g++.dg/tm/attrib-5.C b/gcc/testsuite/g++.dg/tm/attrib-5.C
new file mode 100644 (file)
index 0000000..0b7bc72
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/94733
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+struct [[gnu::may_alias]] pe { };