From e72028574f776fd5b73de8b974e4ea2d085f1532 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 15 Feb 2017 18:10:40 +0100 Subject: [PATCH] re PR c++/79301 (With -Werror=pedantic outside C++17 mode, __has_cpp_attribute(fallthrough) is nonzero but [[fallthrough]] fails) PR c++/79301 * parser.c (cp_parser_std_attribute): Don't pedwarn about [[deprecated]] with -std=c++11 and [[fallthrough]] with -std=c++11 and -std=c++14. * g++.dg/cpp1y/feat-cxx11-neg.C: Remove (with pedwarn) from [[deprecated]] comment. * g++.dg/cpp1y/feat-cxx98-neg.C: Likewise. * g++.dg/cpp1y/feat-cxx11.C: Likewise. * g++.dg/cpp1y/attr-deprecated-neg.C: Don't expect warnings for [[deprecated]] in -std=c++11. * g++.dg/cpp0x/fallthrough2.C: Don't expect warnings for [[fallthrough]] in -std=c++11 and -std=c++14. From-SVN: r245489 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 16 ++-------------- gcc/testsuite/ChangeLog | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/fallthrough2.C | 2 +- gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C | 8 ++++---- gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C | 2 +- gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C | 2 +- gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C | 2 +- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 74f5fc9b784..b281f0b0c70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-02-15 Jakub Jelinek + PR c++/79301 + * parser.c (cp_parser_std_attribute): Don't pedwarn about + [[deprecated]] with -std=c++11 and [[fallthrough]] with + -std=c++11 and -std=c++14. + PR c++/79288 * decl.c (grokdeclarator): For static data members, handle thread_p only after handling inline. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ccafefd2c00..cd41ee6a3c3 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24749,22 +24749,10 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns) TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); /* C++14 deprecated attribute is equivalent to GNU's. */ else if (is_attribute_p ("deprecated", attr_id)) - { - if (cxx_dialect == cxx11) - pedwarn (token->location, OPT_Wpedantic, - "% is a C++14 feature;" - " use %"); - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); - } + TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); /* C++17 fallthrough attribute is equivalent to GNU's. */ else if (is_attribute_p ("fallthrough", attr_id)) - { - if (cxx_dialect < cxx1z) - pedwarn (token->location, OPT_Wpedantic, - "% is a C++17 feature;" - " use %"); - TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); - } + TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); /* Transactional Memory TS optimize_for_synchronized attribute is equivalent to GNU transaction_callable. */ else if (is_attribute_p ("optimize_for_synchronized", attr_id)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5df5da8827b..f749fb7dbc9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,15 @@ 2017-02-15 Jakub Jelinek + PR c++/79301 + * g++.dg/cpp1y/feat-cxx11-neg.C: Remove (with pedwarn) from + [[deprecated]] comment. + * g++.dg/cpp1y/feat-cxx98-neg.C: Likewise. + * g++.dg/cpp1y/feat-cxx11.C: Likewise. + * g++.dg/cpp1y/attr-deprecated-neg.C: Don't expect warnings for + [[deprecated]] in -std=c++11. + * g++.dg/cpp0x/fallthrough2.C: Don't expect warnings for + [[fallthrough]] in -std=c++11 and -std=c++14. + PR c++/79288 * g++.dg/tls/pr79288.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/fallthrough2.C b/gcc/testsuite/g++.dg/cpp0x/fallthrough2.C index 075885a8210..f2d0ce1c693 100644 --- a/gcc/testsuite/g++.dg/cpp0x/fallthrough2.C +++ b/gcc/testsuite/g++.dg/cpp0x/fallthrough2.C @@ -11,7 +11,7 @@ f (int i) { case 1: bar (1); - [[fallthrough]]; // { dg-warning ".fallthrough. is a C\\+\\+17 feature" "" { target { c++14_down } } } + [[fallthrough]]; case 3: bar (1); [[gnu::fallthrough, gnu::fallthrough]]; // { dg-warning ".fallthrough. attribute specified multiple times" } diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C index 369f3df9961..3c5646c3993 100644 --- a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C @@ -1,22 +1,22 @@ // { dg-do compile { target c++11_only } } // { dg-options "-pedantic" } -class [[deprecated]] A // { dg-warning "'deprecated' is a C..14 feature" } +class [[deprecated]] A // { dg-bogus "'deprecated' is a C..14 feature" } { }; -[[deprecated]] // { dg-warning "'deprecated' is a C..14 feature" } +[[deprecated]] // { dg-bogus "'deprecated' is a C..14 feature" } int foo(int n) { return 42 + n; } -class [[deprecated("B has been superceded by C")]] B // { dg-warning "'deprecated' is a C..14 feature" } +class [[deprecated("B has been superceded by C")]] B // { dg-bogus "'deprecated' is a C..14 feature" } { }; -[[deprecated("bar is unsafe; use foobar instead")]] // { dg-warning "'deprecated' is a C..14 feature" } +[[deprecated("bar is unsafe; use foobar instead")]] // { dg-bogus "'deprecated' is a C..14 feature" } int bar(int n) { diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C index 825d0880f58..8d68aaa2b83 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11-neg.C @@ -57,7 +57,7 @@ // C++14 attributes: -// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +// Attribute [[deprecated]] is allowed in C++11 as an extension. //#ifdef __has_cpp_attribute //# if __has_cpp_attribute(deprecated) == 201309 //# error "__has_cpp_attribute(deprecated)" // { } diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C index 2f3b01efc38..98112218d8f 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C @@ -166,7 +166,7 @@ // C++14 attributes: -// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +// Attribute [[deprecated]] is allowed in C++11 as an extension. #ifdef __has_cpp_attribute # if ! __has_cpp_attribute(deprecated) # error "__has_cpp_attribute(deprecated)" diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C index 5fbffabd139..d76a1e2617d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98-neg.C @@ -144,7 +144,7 @@ // C++14 attributes: -// Attribute [[deprecated]] is allowed in C++11 as an extension (with pedwarn). +// Attribute [[deprecated]] is allowed in C++11 as an extension. //#ifdef __has_cpp_attribute //# if __has_cpp_attribute(deprecated) == 201309 //# error "__has_cpp_attribute(deprecated)" // { } -- 2.30.2