From 1d500c25165a5b708f1fc2088ba63c93a2c1eb94 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 13 Mar 2018 11:55:44 -0400 Subject: [PATCH] Pedwarn about auto parameter even without -Wpedantic. * parser.c (cp_parser_simple_type_specifier): Pedwarn about auto parameter even without -Wpedantic. From-SVN: r258494 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/parser.c | 6 +++--- gcc/testsuite/g++.dg/{cpp1z => concepts}/abbrev1.C | 3 ++- gcc/testsuite/g++.dg/{cpp1z => concepts}/abbrev2.C | 4 ++-- .../g++.dg/{cpp1y => concepts}/fn-generic-member-ool.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58500.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58534.C | 2 +- gcc/testsuite/g++.dg/concepts/pr58535.C | 7 +++++++ gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58536.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58548.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58549.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60052.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60053.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60064.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60065.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60377.C | 3 +-- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60390.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60391.C | 3 +-- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60573.C | 2 +- gcc/testsuite/g++.dg/{cpp1y => concepts}/pr80471.C | 2 +- gcc/testsuite/g++.dg/cpp0x/auto-60626.C | 6 ++++++ .../g++.dg/{cpp1y/pr84662.C => cpp0x/auto-84662.C} | 3 +-- gcc/testsuite/g++.dg/cpp1y/pr58535.C | 8 -------- gcc/testsuite/g++.dg/cpp1y/pr60626.C | 7 ------- gcc/testsuite/g++.dg/cpp1z/decomp3.C | 2 +- 25 files changed, 40 insertions(+), 41 deletions(-) rename gcc/testsuite/g++.dg/{cpp1z => concepts}/abbrev1.C (70%) rename gcc/testsuite/g++.dg/{cpp1z => concepts}/abbrev2.C (79%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/fn-generic-member-ool.C (93%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58500.C (69%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58534.C (79%) create mode 100644 gcc/testsuite/g++.dg/concepts/pr58535.C rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58536.C (69%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58548.C (69%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr58549.C (67%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60052.C (77%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60053.C (81%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60064.C (82%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60065.C (85%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60377.C (50%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60390.C (84%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60391.C (53%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr60573.C (90%) rename gcc/testsuite/g++.dg/{cpp1y => concepts}/pr80471.C (92%) create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto-60626.C rename gcc/testsuite/g++.dg/{cpp1y/pr84662.C => cpp0x/auto-84662.C} (57%) delete mode 100644 gcc/testsuite/g++.dg/cpp1y/pr58535.C delete mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60626.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d480c1bafba..0da60a3e99b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-03-13 Jason Merrill + * parser.c (cp_parser_simple_type_specifier): Pedwarn about auto + parameter even without -Wpedantic. + PR c++/84798 - ICE with auto in abstract function declarator. * parser.c (cp_parser_parameter_declaration_clause): Check parser->default_arg_ok_p. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8e8ebceb0d5..0a82f415196 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17049,9 +17049,9 @@ cp_parser_simple_type_specifier (cp_parser* parser, "only available with " "-std=c++14 or -std=gnu++14"); else if (!flag_concepts) - pedwarn (token->location, OPT_Wpedantic, - "ISO C++ forbids use of % in parameter " - "declaration"); + pedwarn (token->location, 0, + "use of % in parameter declaration " + "only available with -fconcepts"); } else type = make_auto (); diff --git a/gcc/testsuite/g++.dg/cpp1z/abbrev1.C b/gcc/testsuite/g++.dg/concepts/abbrev1.C similarity index 70% rename from gcc/testsuite/g++.dg/cpp1z/abbrev1.C rename to gcc/testsuite/g++.dg/concepts/abbrev1.C index 3caa814c58d..8de681f2db6 100644 --- a/gcc/testsuite/g++.dg/cpp1z/abbrev1.C +++ b/gcc/testsuite/g++.dg/concepts/abbrev1.C @@ -1,5 +1,6 @@ // PR c++/64969 -// { dg-options "-std=c++17" } +// { dg-do compile { target c++14 } } +// { dg-additional-options "-fconcepts" } auto f1(auto x) { return *x; } decltype(auto) f2(auto x) { return *x; } diff --git a/gcc/testsuite/g++.dg/cpp1z/abbrev2.C b/gcc/testsuite/g++.dg/concepts/abbrev2.C similarity index 79% rename from gcc/testsuite/g++.dg/cpp1z/abbrev2.C rename to gcc/testsuite/g++.dg/concepts/abbrev2.C index 1dc6af3a57d..3100f67254e 100644 --- a/gcc/testsuite/g++.dg/cpp1z/abbrev2.C +++ b/gcc/testsuite/g++.dg/concepts/abbrev2.C @@ -1,6 +1,6 @@ // PR c++/66197 -// { dg-do run } -// { dg-options "-std=c++17" } +// { dg-do run { target c++14 } } +// { dg-additional-options "-fconcepts" } extern "C" void abort(); diff --git a/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C b/gcc/testsuite/g++.dg/concepts/fn-generic-member-ool.C similarity index 93% rename from gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C rename to gcc/testsuite/g++.dg/concepts/fn-generic-member-ool.C index 60ac52eff5b..b664ccf3da1 100644 --- a/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C +++ b/gcc/testsuite/g++.dg/concepts/fn-generic-member-ool.C @@ -1,6 +1,6 @@ // Out-of-line generic member function definitions. // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { void f(auto x); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58500.C b/gcc/testsuite/g++.dg/concepts/pr58500.C similarity index 69% rename from gcc/testsuite/g++.dg/cpp1y/pr58500.C rename to gcc/testsuite/g++.dg/concepts/pr58500.C index bb68cbc1999..cb74072a570 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58500.C +++ b/gcc/testsuite/g++.dg/concepts/pr58500.C @@ -1,6 +1,6 @@ // PR c++/58500 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A {}; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58534.C b/gcc/testsuite/g++.dg/concepts/pr58534.C similarity index 79% rename from gcc/testsuite/g++.dg/cpp1y/pr58534.C rename to gcc/testsuite/g++.dg/concepts/pr58534.C index e38e1f3f667..b2c3caac63c 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58534.C +++ b/gcc/testsuite/g++.dg/concepts/pr58534.C @@ -1,6 +1,6 @@ // PR c++/58534 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } template void foo(const auto&) {} diff --git a/gcc/testsuite/g++.dg/concepts/pr58535.C b/gcc/testsuite/g++.dg/concepts/pr58535.C new file mode 100644 index 00000000000..3e212a0ffd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr58535.C @@ -0,0 +1,7 @@ +// PR c++/58535 +// { dg-do compile { target c++14 } } + +struct A +{ + virtual void foo(auto); // { dg-error "auto|templates" } +}; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58536.C b/gcc/testsuite/g++.dg/concepts/pr58536.C similarity index 69% rename from gcc/testsuite/g++.dg/cpp1y/pr58536.C rename to gcc/testsuite/g++.dg/concepts/pr58536.C index a4b6f553efd..99c7ebee309 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58536.C +++ b/gcc/testsuite/g++.dg/concepts/pr58536.C @@ -1,6 +1,6 @@ // PR c++/58536 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58548.C b/gcc/testsuite/g++.dg/concepts/pr58548.C similarity index 69% rename from gcc/testsuite/g++.dg/cpp1y/pr58548.C rename to gcc/testsuite/g++.dg/concepts/pr58548.C index 6a78de46c3f..cd3e6fdb2dc 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58548.C +++ b/gcc/testsuite/g++.dg/concepts/pr58548.C @@ -1,6 +1,6 @@ // PR c++/58548 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } void foo(auto) { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58549.C b/gcc/testsuite/g++.dg/concepts/pr58549.C similarity index 67% rename from gcc/testsuite/g++.dg/cpp1y/pr58549.C rename to gcc/testsuite/g++.dg/concepts/pr58549.C index 2f76399d8dd..6b66afc1ad2 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr58549.C +++ b/gcc/testsuite/g++.dg/concepts/pr58549.C @@ -1,6 +1,6 @@ // PR c++/58549 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } void foo(auto) { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60052.C b/gcc/testsuite/g++.dg/concepts/pr60052.C similarity index 77% rename from gcc/testsuite/g++.dg/cpp1y/pr60052.C rename to gcc/testsuite/g++.dg/concepts/pr60052.C index 25d20acdf84..c5bc28efd07 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60052.C +++ b/gcc/testsuite/g++.dg/concepts/pr60052.C @@ -1,6 +1,6 @@ // PR c++/60052 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60053.C b/gcc/testsuite/g++.dg/concepts/pr60053.C similarity index 81% rename from gcc/testsuite/g++.dg/cpp1y/pr60053.C rename to gcc/testsuite/g++.dg/concepts/pr60053.C index a8f5ba1ca3f..20cf1216b0e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60053.C +++ b/gcc/testsuite/g++.dg/concepts/pr60053.C @@ -1,6 +1,6 @@ // PR c++/60053 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60064.C b/gcc/testsuite/g++.dg/concepts/pr60064.C similarity index 82% rename from gcc/testsuite/g++.dg/cpp1y/pr60064.C rename to gcc/testsuite/g++.dg/concepts/pr60064.C index add3f05cbbd..b82b560d1f5 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60064.C +++ b/gcc/testsuite/g++.dg/concepts/pr60064.C @@ -1,6 +1,6 @@ // PR c++/60064 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } class A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60065.C b/gcc/testsuite/g++.dg/concepts/pr60065.C similarity index 85% rename from gcc/testsuite/g++.dg/cpp1y/pr60065.C rename to gcc/testsuite/g++.dg/concepts/pr60065.C index 56505b7bc04..b2b1aea433e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60065.C +++ b/gcc/testsuite/g++.dg/concepts/pr60065.C @@ -1,6 +1,6 @@ // PR c++/60065 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } template void foo(auto... x); template void foo2(auto... x); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60377.C b/gcc/testsuite/g++.dg/concepts/pr60377.C similarity index 50% rename from gcc/testsuite/g++.dg/cpp1y/pr60377.C rename to gcc/testsuite/g++.dg/concepts/pr60377.C index ab35ba9b172..5b1871735c8 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60377.C +++ b/gcc/testsuite/g++.dg/concepts/pr60377.C @@ -1,8 +1,7 @@ // PR c++/60377 // { dg-do compile { target c++14 } } -// { dg-options "" } -void foo(auto, void (f*)()); // { dg-error "expected" } +void foo(auto, void (f*)()); // { dg-error "auto|expected" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60390.C b/gcc/testsuite/g++.dg/concepts/pr60390.C similarity index 84% rename from gcc/testsuite/g++.dg/cpp1y/pr60390.C rename to gcc/testsuite/g++.dg/concepts/pr60390.C index 38d0e4bd6cd..a453d1d61a3 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60390.C +++ b/gcc/testsuite/g++.dg/concepts/pr60390.C @@ -1,6 +1,6 @@ // PR c++/60390 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60391.C b/gcc/testsuite/g++.dg/concepts/pr60391.C similarity index 53% rename from gcc/testsuite/g++.dg/cpp1y/pr60391.C rename to gcc/testsuite/g++.dg/concepts/pr60391.C index 7e3570498bc..5c5ca2c2381 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60391.C +++ b/gcc/testsuite/g++.dg/concepts/pr60391.C @@ -1,10 +1,9 @@ // PR c++/60391 // { dg-do compile { target c++14 } } -// { dg-options "" } namespace N { - int operator"" _X(auto) {} // { dg-error "invalid" } + int operator"" _X(auto) {} // { dg-error "auto|invalid" } } namespace N {} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60573.C b/gcc/testsuite/g++.dg/concepts/pr60573.C similarity index 90% rename from gcc/testsuite/g++.dg/cpp1y/pr60573.C rename to gcc/testsuite/g++.dg/concepts/pr60573.C index da730f80f06..568849175c6 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60573.C +++ b/gcc/testsuite/g++.dg/concepts/pr60573.C @@ -1,6 +1,6 @@ // PR c++/60573 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr80471.C b/gcc/testsuite/g++.dg/concepts/pr80471.C similarity index 92% rename from gcc/testsuite/g++.dg/cpp1y/pr80471.C rename to gcc/testsuite/g++.dg/concepts/pr80471.C index bca4022cf57..d5fa5a536d3 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr80471.C +++ b/gcc/testsuite/g++.dg/concepts/pr80471.C @@ -1,6 +1,6 @@ // PR c++/80471 // { dg-do compile { target c++14 } } -// { dg-options "" } +// { dg-additional-options "-fconcepts" } template constexpr bool is_same = false; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto-60626.C b/gcc/testsuite/g++.dg/cpp0x/auto-60626.C new file mode 100644 index 00000000000..35671924ea9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto-60626.C @@ -0,0 +1,6 @@ +// PR c++/60626 +// { dg-do compile { target c++14 } } + +struct A {}; + +void (*A::p)(auto) = 0; // { dg-error "auto|static data member|template" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84662.C b/gcc/testsuite/g++.dg/cpp0x/auto-84662.C similarity index 57% rename from gcc/testsuite/g++.dg/cpp1y/pr84662.C rename to gcc/testsuite/g++.dg/cpp0x/auto-84662.C index 36bd201073e..271fb56f7eb 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr84662.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto-84662.C @@ -1,6 +1,5 @@ // PR c++/84662 // { dg-do compile { target c++14 } } -// { dg-options "" } double b; -a (__attribute__((c (0 && int() - ([] {} && b) || auto)))); // { dg-error "expected constructor, destructor, or type conversion before" } +a (__attribute__((c (0 && int() - ([] {} && b) || auto)))); // { dg-error "auto|expected constructor, destructor, or type conversion before" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58535.C b/gcc/testsuite/g++.dg/cpp1y/pr58535.C deleted file mode 100644 index b36be8f4a45..00000000000 --- a/gcc/testsuite/g++.dg/cpp1y/pr58535.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/58535 -// { dg-do compile { target c++14 } } -// { dg-options "" } - -struct A -{ - virtual void foo(auto); // { dg-error "templates" } -}; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60626.C b/gcc/testsuite/g++.dg/cpp1y/pr60626.C deleted file mode 100644 index 311464472da..00000000000 --- a/gcc/testsuite/g++.dg/cpp1y/pr60626.C +++ /dev/null @@ -1,7 +0,0 @@ -// PR c++/60626 -// { dg-do compile { target c++14 } } -// { dg-options "" } - -struct A {}; - -void (*A::p)(auto) = 0; // { dg-error "static data member|template" } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp3.C b/gcc/testsuite/g++.dg/cpp1z/decomp3.C index 529f3732fd5..1886cdbe90d 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp3.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp3.C @@ -43,7 +43,7 @@ test (A &b, B c) void test2 (auto & [ p ] = bar ()) // { dg-error "'p' was not declared in this scope" } -{ +{ // { dg-warning "auto" "" { target { ! concepts } } .-1 } } int arr[4]; -- 2.30.2