From: Jakub Jelinek Date: Thu, 7 Jul 2016 21:46:54 +0000 (+0200) Subject: backport: re PR c++/67767 (-Wsuggest-attribute=noreturn suggests noreturn for functio... X-Git-Tag: releases/gcc-4.9.4~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28fdf5350122d522d866b01987a2fdd60bddeab4;p=thirdparty%2Fgcc.git backport: re PR c++/67767 (-Wsuggest-attribute=noreturn suggests noreturn for function which already has noreturn and cold.) Backported from mainline 2016-02-19 Jakub Jelinek 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e0c2154f86b..c3da35e71da1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2016-07-07 Jakub Jelinek + + Backported from mainline + 2016-02-19 Jakub Jelinek + + 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 PR c++/70505 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index cc5568912510..50ce667ad48e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c07963b222d4..7fc70834ed63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2016-07-07 Jakub Jelinek Backported from mainline + 2016-02-19 Jakub Jelinek + + PR c++/67767 + * g++.dg/cpp0x/pr67767.C: New test. + 2016-02-16 Jakub Jelinek 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 index 000000000000..fd4ae2d3f350 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr67767.C @@ -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; +}