Hi,
while working on the last patch I noticed a few more cases of warning_at
and permerror pairs where it makes sense to use inform.
Tested x86_64-linux.
Thanks,
Paolo.
///////////////////////////
/cp
2013-05-15 Paolo Carlini <paolo.carl...@oracle.com>
* name-lookup.c (pushdecl_maybe_friend_1): Replace pairs of
warning_at and permerror to warning_at / inform and permerror /
inform, respectively.
/testsuite
2013-05-15 Paolo Carlini <paolo.carl...@oracle.com>
* 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.
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c (revision 198939)
+++ cp/name-lookup.c (working copy)
@@ -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");
}
}
}
Index: testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C (revision 198936)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C (working copy)
@@ -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;
};
Index: testsuite/g++.dg/warn/Wshadow-1.C
===================================================================
--- testsuite/g++.dg/warn/Wshadow-1.C (revision 198936)
+++ testsuite/g++.dg/warn/Wshadow-1.C (working copy)
@@ -18,8 +18,8 @@ struct status // { dg-bogus "shadowed
declaratio
}
};
-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" }
}
Index: testsuite/g++.dg/warn/Wshadow-6.C
===================================================================
--- testsuite/g++.dg/warn/Wshadow-6.C (revision 198936)
+++ testsuite/g++.dg/warn/Wshadow-6.C (working copy)
@@ -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 @@ struct S {};
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 <class T>
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;
};
Index: testsuite/g++.dg/warn/Wshadow-7.C
===================================================================
--- testsuite/g++.dg/warn/Wshadow-7.C (revision 198936)
+++ testsuite/g++.dg/warn/Wshadow-7.C (working copy)
@@ -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" }