From 1e6cf26ea81901fb00daef06d74966bcacbd99eb Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 15 May 2013 18:24:31 +0000 Subject: [PATCH] name-lookup.c (pushdecl_maybe_friend_1): Replace pairs of warning_at and permerror with warning_at/inform and permerror/... /cp 2013-05-15 Paolo Carlini * name-lookup.c (pushdecl_maybe_friend_1): Replace pairs of warning_at and permerror with warning_at/inform and permerror/ inform, respectively. /testsuite 2013-05-15 Paolo Carlini * g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with dg-messages. * g++.dg/warn/Wshadow-1.C: Likewise. * g++.dg/warn/Wshadow-6.C: Likewise. * g++.dg/warn/Wshadow-7.C: Likewise. From-SVN: r198943 --- gcc/cp/ChangeLog | 6 ++++ gcc/cp/name-lookup.c | 29 ++++++++++++------- gcc/testsuite/ChangeLog | 8 +++++ .../g++.dg/cpp0x/lambda/lambda-shadow1.C | 2 +- gcc/testsuite/g++.dg/warn/Wshadow-1.C | 6 ++-- gcc/testsuite/g++.dg/warn/Wshadow-6.C | 12 ++++---- gcc/testsuite/g++.dg/warn/Wshadow-7.C | 10 +++---- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cf91769b72f..a602af3addb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-15 Paolo Carlini + + * name-lookup.c (pushdecl_maybe_friend_1): Replace pairs of + warning_at and permerror with warning_at/inform and permerror/ + inform, respectively. + 2013-05-15 Paolo Carlini PR c++/31952 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index a60504fafdf..17d5ca26516 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -943,8 +943,10 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) && TREE_CODE (decl) == TREE_CODE (x) && !same_type_p (TREE_TYPE (x), TREE_TYPE (decl))) { - permerror (input_location, "type mismatch with previous external decl of %q#D", x); - permerror (input_location, "previous external decl of %q+#D", decl); + if (permerror (input_location, "type mismatch with previous " + "external decl of %q#D", x)) + inform (input_location, "previous external decl of %q+#D", + decl); } } @@ -1161,19 +1163,23 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) if (warn_shadow && !nowarn) { + bool warned; + if (TREE_CODE (oldlocal) == PARM_DECL) - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %q#D shadows a parameter", x); else if (is_capture_proxy (oldlocal)) - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %qD shadows a lambda capture", x); else - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %qD shadows a previous local", x); - warning_at (DECL_SOURCE_LOCATION (oldlocal), OPT_Wshadow, - "shadowed declaration is here"); + + if (warned) + inform (DECL_SOURCE_LOCATION (oldlocal), + "shadowed declaration is here"); } } @@ -1213,10 +1219,11 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) || TREE_CODE (x) == TYPE_DECL)))) /* XXX shadow warnings in outer-more namespaces */ { - warning_at (input_location, OPT_Wshadow, - "declaration of %qD shadows a global declaration", x); - warning_at (DECL_SOURCE_LOCATION (oldglobal), OPT_Wshadow, - "shadowed declaration is here"); + if (warning_at (input_location, OPT_Wshadow, + "declaration of %qD shadows a " + "global declaration", x)) + inform (DECL_SOURCE_LOCATION (oldglobal), + "shadowed declaration is here"); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55315f49faa..be7ccece6a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2013-05-15 Paolo Carlini + + * g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with + dg-messages. + * g++.dg/warn/Wshadow-1.C: Likewise. + * g++.dg/warn/Wshadow-6.C: Likewise. + * g++.dg/warn/Wshadow-7.C: Likewise. + 2013-05-15 Paolo Carlini PR c++/31952 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C index bb06bfe4afa..f4433faec92 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C @@ -2,7 +2,7 @@ // { dg-options "-std=c++11 -Wshadow" } int main() { - int x = 1; // { dg-warning "shadowed" } + int x = 1; // { dg-message "shadowed" } auto const lambda = [](int x) { // { dg-warning "shadows" } return x; }; diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-1.C b/gcc/testsuite/g++.dg/warn/Wshadow-1.C index 1647a010d12..aec6bca5418 100644 --- a/gcc/testsuite/g++.dg/warn/Wshadow-1.C +++ b/gcc/testsuite/g++.dg/warn/Wshadow-1.C @@ -18,8 +18,8 @@ struct status // { dg-bogus "shadowed declaration" } } }; -int decl1; // { dg-warning "shadowed declaration" } -int decl2; // { dg-warning "shadowed declaration" } +int decl1; // { dg-message "shadowed declaration" } +int decl2; // { dg-message "shadowed declaration" } void foo (struct status &status,// { dg-bogus "shadows a global decl" } double decl1) // { dg-warning "shadows a global decl" } { @@ -34,7 +34,7 @@ void status::foo2 () { int member; // { dg-warning "shadows a member" } int decl2; // { dg-warning "shadows a global decl" } - int local; // { dg-warning "shadowed declaration" } + int local; // { dg-message "shadowed declaration" } { int local; // { dg-warning "shadows a previous local" } } diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-6.C b/gcc/testsuite/g++.dg/warn/Wshadow-6.C index fdc37df31b4..78275743115 100644 --- a/gcc/testsuite/g++.dg/warn/Wshadow-6.C +++ b/gcc/testsuite/g++.dg/warn/Wshadow-6.C @@ -4,10 +4,10 @@ // { dg-options "-std=c++0x -Wshadow" } struct S {}; -int f1(int x) // { dg-warning "shadowed declaration" } +int f1(int x) // { dg-message "shadowed declaration" } { int t = 0; - int m = 0; // { dg-warning "shadowed declaration" } + int m = 0; // { dg-message "shadowed declaration" } [&t] (int x) { // { dg-warning "shadows a parameter" } int m = 1; // { dg-warning "shadows a previous local" } t = t + x + m; @@ -18,9 +18,9 @@ int f1(int x) // { dg-warning "shadowed declaration" } void f2(struct S i, int j) { struct A { struct S x; - void g(struct S i) { // { dg-warning "shadowed declaration" } + void g(struct S i) { // { dg-message "shadowed declaration" } struct S x; // { dg-warning "shadows a member of" } - struct S y; // { dg-warning "shadowed declaration" } + struct S y; // { dg-message "shadowed declaration" } int t; [&t](struct S i){ // { dg-warning "shadows a parameter" } int j = 1; // { dg-bogus "shadows" } @@ -33,7 +33,7 @@ void f2(struct S i, int j) { void f3(int i) { [=]{ - int j = i; // { dg-warning "shadowed declaration" } + int j = i; // { dg-message "shadowed declaration" } int i; // { dg-warning "shadows a lambda capture" } i = 1; }; @@ -42,7 +42,7 @@ void f3(int i) { template void f4(int i) { [=]{ - int j = i; // { dg-warning "shadowed declaration" } + int j = i; // { dg-message "shadowed declaration" } int i; // { dg-warning "shadows a lambda capture" } i = 1; }; diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-7.C b/gcc/testsuite/g++.dg/warn/Wshadow-7.C index 5de952ee790..d354d0499f4 100644 --- a/gcc/testsuite/g++.dg/warn/Wshadow-7.C +++ b/gcc/testsuite/g++.dg/warn/Wshadow-7.C @@ -1,18 +1,18 @@ // PR c++/44128 // { dg-options "-Wshadow" } -typedef long My_ssize_t; // { dg-warning "shadowed declaration" } -typedef int Foo; // { dg-warning "shadowed declaration" } +typedef long My_ssize_t; // { dg-message "shadowed declaration" } +typedef int Foo; // { dg-message "shadowed declaration" } struct Bar1 { // { dg-bogus "shadowed declaration" } int a; }; -struct Bar2 { // { dg-warning "shadowed declaration" } +struct Bar2 { // { dg-message "shadowed declaration" } int a; }; void func() { typedef int My_ssize_t; // { dg-warning "shadows a global" } - typedef char My_Num; // { dg-warning "shadowed declaration" } + typedef char My_Num; // { dg-message "shadowed declaration" } { typedef short My_Num; // { dg-warning "shadows a previous local" } } @@ -21,7 +21,7 @@ void func() { struct Bar2 { // { dg-warning "shadows a global" } int a; }; - struct Bar3 { // { dg-warning "shadowed declaration" } + struct Bar3 { // { dg-message "shadowed declaration" } int a; }; struct Bar4 { // { dg-bogus "shadowed declaration" }