diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 57cd76caf4903df71079683a29092bc08e43897f..4a9e9aa3cdcbe0381fa73217828c175dd199c1e7 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -4735,9 +4735,10 @@ maybe_warn_cpp0x (cpp0x_warn_str str, location_t loc/*=input_location*/) "only available with %<-std=c++11%> or %<-std=gnu++11%>"); break; case CPP0X_ATTRIBUTES: - pedwarn (loc, OPT_Wc__11_extensions, - "C++11 attributes " - "only available with %<-std=c++11%> or %<-std=gnu++11%>"); + if (pedantic) + pedwarn (loc, OPT_Wc__11_extensions, + "C++11 attributes " + "only available with %<-std=c++11%> or %<-std=gnu++11%>"); break; case CPP0X_REF_QUALIFIER: pedwarn (loc, OPT_Wc__11_extensions, diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index edfa5a494405f8ad79b04ac3f027abc255caeff7..64122d937fa505c1e4cebd6ab6a9639df552d357 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -29924,11 +29924,10 @@ cp_nth_tokens_can_be_std_attribute_p (cp_parser *parser, size_t n) { cp_token *token = cp_lexer_peek_nth_token (parser->lexer, n); - return (cxx_dialect >= cxx11 - && ((token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS) - || (token->type == CPP_OPEN_SQUARE - && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1)) - && token->type == CPP_OPEN_SQUARE))); + return ((token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS) + || (token->type == CPP_OPEN_SQUARE + && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1)) + && token->type == CPP_OPEN_SQUARE)); } /* Return TRUE iff the next Nth tokens in the stream are possibly the diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-1.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-1.C index c2cf912047e9803493cece9693d87e22dfe62aa1..b1625d9691675ee4bfc6b3d8a0b8b13997a6e37f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-1.C @@ -1,3 +1,3 @@ -// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-c++11-extensions" } int **** [[gnu::format(printf, 1, 2)]] foo(const char *, ...); // { dg-warning "only applies to function types" } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-11.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-11.C index 504b4565679c489469a7663e9d108e6987911cfd..040f15c9dbb94bcda3d7040b1ade0b94c75028e3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-11.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-11.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-c++11-extensions" } // PR c++/13791 template <typename T> struct O { diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-13.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-13.C index a1b4a84b7e5494f252ea4fa4888635117ec09f9b..8997b845dfd95270cf57f72bc8942c011467a3c6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-13.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-13.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-c++11-extensions" } // PR c++/13854 extern char *rindex [[gnu::__pure__]] (__const char *__s, int __c) throw (); diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-15.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-15.C index bf05dbeb31b96ff9ac72f8cb36abb56a4ed55ec3..8b552ca1fbe2dfaced7036965c25bce2d511a322 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-15.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-15.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-c++11-extensions" } // PR c++/15317 struct A diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-75.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-75.C index bac80aa02ffb015b6ca11a364ddcbe2da594550e..c2a328c7c7ffc09b9053f03fcf083091e25239a4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-75.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-75.C @@ -1,6 +1,6 @@ // PR c++/101582 // { dg-do compile } -// { dg-options "" } +// { dg-options "-pedantic -Wno-extra-semi" } ; [[]] [[]] [[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } @@ -12,9 +12,9 @@ extern "C" [[]]; // { dg-warning "attributes only available with" "" { target c+ extern "C" extern "C" ; extern "C" extern "C" [[]][[]][[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } __extension__ ; -__extension__ [[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } +__extension__ [[]]; __extension__ __extension__ ; -__extension__ __extension__ [[]][[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } +__extension__ __extension__ [[]][[]]; namespace N { @@ -28,8 +28,8 @@ extern "C" [[]]; // { dg-warning "attributes only available with" "" { target c+ extern "C" extern "C" ; extern "C" extern "C" [[]][[]][[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } __extension__ ; -__extension__ [[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } +__extension__ [[]]; __extension__ __extension__ ; -__extension__ __extension__ [[]][[]]; // { dg-warning "attributes only available with" "" { target c++98_only } } +__extension__ __extension__ [[]][[]]; }