]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/67767 (-Wsuggest-attribute=noreturn suggests noreturn for functio...
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2016 21:46:54 +0000 (23:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2016 21:46:54 +0000 (23:46 +0200)
Backported from mainline
2016-02-19  Jakub Jelinek  <jakub@redhat.com>

PR c++/67767
* parser.c (cp_parser_std_attribute_spec_seq): Don't assume
attr_spec is always single element chain, chain all the attributes
properly together in the right order.

* g++.dg/cpp0x/pr67767.C: New test.

From-SVN: r238136

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr67767.C [new file with mode: 0644]

index 6e0c2154f86bcbaebbb749c956ef36e9a0e77867..c3da35e71da1ed027fd3c3d1eacf84496d9a87bf 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-07  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2016-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/67767
+       * parser.c (cp_parser_std_attribute_spec_seq): Don't assume
+       attr_spec is always single element chain, chain all the attributes
+       properly together in the right order.
+
 2016-05-18  Jason Merrill  <jason@redhat.com>
 
        PR c++/70505
index cc55689125106883ae073a3fc3eb73dac4ced866..50ce667ad48e7b46357165ebda34a42ddd57fe12 100644 (file)
@@ -22047,7 +22047,8 @@ cp_parser_std_attribute_spec (cp_parser *parser)
 static tree
 cp_parser_std_attribute_spec_seq (cp_parser *parser)
 {
-  tree attr_specs = NULL;
+  tree attr_specs = NULL_TREE;
+  tree attr_last = NULL_TREE;
 
   while (true)
     {
@@ -22057,11 +22058,13 @@ cp_parser_std_attribute_spec_seq (cp_parser *parser)
       if (attr_spec == error_mark_node)
        return error_mark_node;
 
-      TREE_CHAIN (attr_spec) = attr_specs;
-      attr_specs = attr_spec;
+      if (attr_last)
+       TREE_CHAIN (attr_last) = attr_spec;
+      else
+       attr_specs = attr_last = attr_spec;
+      attr_last = tree_last (attr_last);
     }
 
-  attr_specs = nreverse (attr_specs);
   return attr_specs;
 }
 
index c07963b222d45ad760be176e80b8ee043c43172d..7fc70834ed63fdff27bac7ce73be54112ffec468 100644 (file)
@@ -1,6 +1,11 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/67767
+       * g++.dg/cpp0x/pr67767.C: New test.
+
        2016-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/69802
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr67767.C b/gcc/testsuite/g++.dg/cpp0x/pr67767.C
new file mode 100644 (file)
index 0000000..fd4ae2d
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/67767
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wsuggest-attribute=noreturn" }
+
+void foo [[gnu::cold, gnu::noreturn]] ();
+
+void foo ()    // { dg-bogus "function might be candidate for attribute" }
+{
+  throw 1;
+}