Patchwork [C] Use inform for "shadowed decl" (PR c/48062)

login
register
mail settings
Submitter Marek Polacek
Date June 3, 2014, 4:01 p.m.
Message ID <20140603160157.GE29196@redhat.com>
Download mbox | patch
Permalink /patch/355584/
State New
Headers show

Comments

Marek Polacek - June 3, 2014, 4:01 p.m.
For "shadowed declaration" note we were calling warning_at, while we
should use inform.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-06-03  Marek Polacek  <polacek@redhat.com>

	PR c/48062
	* c-decl.c (warn_if_shadowing): Call inform instead of warning_at.

	* gcc.dg/Wshadow-1.c: Use dg-message for "shadowed declaration".
	* gcc.dg/Wshadow-3.c: Likewise.


	Marek
Jakub Jelinek - June 3, 2014, 4:07 p.m.
On Tue, Jun 03, 2014 at 06:01:57PM +0200, Marek Polacek wrote:
> For "shadowed declaration" note we were calling warning_at, while we
> should use inform.
> 
> Regtested/bootstrapped on x86_64-linux, ok for trunk?

Shouldn't you remember the return value from warning/warning_at calls
which fall through into this spot and guard the inform call with that?

	Jakub

Patch

diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index dc8dbc2..05ab20e 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -2635,8 +2635,8 @@  warn_if_shadowing (tree new_decl)
 	  warning (OPT_Wshadow, "declaration of %q+D shadows a previous local",
 		   new_decl);
 
-	warning_at (DECL_SOURCE_LOCATION (old_decl), OPT_Wshadow,
-		    "shadowed declaration is here");
+	inform (DECL_SOURCE_LOCATION (old_decl),
+		"shadowed declaration is here");
 
 	break;
       }
diff --git gcc/testsuite/gcc.dg/Wshadow-1.c gcc/testsuite/gcc.dg/Wshadow-1.c
index 40073f3..6075711 100644
--- gcc/testsuite/gcc.dg/Wshadow-1.c
+++ gcc/testsuite/gcc.dg/Wshadow-1.c
@@ -5,7 +5,7 @@ 
 
 /* Source: Neil Booth, 5 Dec 2001.  */
 
-int decl1;			/* { dg-warning "shadowed declaration" } */
+int decl1;			/* { dg-message "shadowed declaration" } */
 void foo (double decl1)		/* { dg-warning "shadows a global decl" } */
 {				
 }
@@ -16,7 +16,7 @@  void foo1 (int d)		/* { dg-message "note: previous definition" } */
   /* { dg-error "redeclared as different" "" { target *-*-* } 15 } */
 }
 
-void foo2 (int d)		/* { dg-warning "shadowed declaration" } */
+void foo2 (int d)		/* { dg-message "shadowed declaration" } */
 {
   {
     double d;			/* { dg-warning "shadows a parameter" } */
@@ -25,7 +25,7 @@  void foo2 (int d)		/* { dg-warning "shadowed declaration" } */
 
 void foo3 ()
 {
-  int local;			/* { dg-warning "shadowed declaration" } */
+  int local;			/* { dg-message "shadowed declaration" } */
   {
     int local;			/* { dg-warning "shadows a previous local" } */
   }
diff --git gcc/testsuite/gcc.dg/Wshadow-3.c gcc/testsuite/gcc.dg/Wshadow-3.c
index a7f06a2..ce2879c 100644
--- gcc/testsuite/gcc.dg/Wshadow-3.c
+++ gcc/testsuite/gcc.dg/Wshadow-3.c
@@ -5,7 +5,7 @@ 
 /* { dg-do compile } */
 /* { dg-options "-std=gnu89 -Wshadow" } */
 
-int v; /* { dg-warning "shadowed declaration" } */
+int v; /* { dg-message "shadowed declaration" } */
 int f1(int v);
 int f2(int v, int x[v]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
 int f3(int v, int y[sizeof(v)]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
@@ -18,4 +18,4 @@  int f9(x) int x; { return 0; }
 int f10(v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
 int f11(int a, int b(int a));
 int f12(int a, int b(int a, int x[a])); /* { dg-warning "declaration of 'a' shadows a parameter" } */
-/* { dg-warning "shadowed declaration" "outer parm" { target *-*-* } 20 } */
+/* { dg-message "shadowed declaration" "outer parm" { target *-*-* } 20 } */