Patchwork Fix error message from -Wcast-qual when casting away volatile

login
register
mail settings
Submitter Gerald Pfeifer
Date March 11, 2014, 4:10 p.m.
Message ID <alpine.LSU.2.11.1403111706350.7314@tuna.site>
Download mbox | patch
Permalink /patch/329152/
State New
Headers show

Comments

Gerald Pfeifer - March 11, 2014, 4:10 p.m.
On Tue, 11 Mar 2014, Magnus Reftel wrote:
> Currently, castring away volatile from a pointer makes -Wcast-qual
> claim that __attribute__((noreturn)) was cast away (see bugzilla
> 55383). The attached patch, originally written by Manuel López-Ibáñez
> and updated to match trunk by me, correctes that. No regressions on
> gcc from applying this patch (as reported by "make check") were seen.
> 
> 2014-03-11 Manuel López-Ibáñez  <manu@gcc.gnu.org>
> 
>  PR c/55383
>  * c/c-typeck.c: use correct format string in cast-qual warning

I volunteer applying this if approved.

Gerald
Jakub Jelinek - March 11, 2014, 4:12 p.m.
On Tue, Mar 11, 2014 at 05:10:45PM +0100, Gerald Pfeifer wrote:
> On Tue, 11 Mar 2014, Magnus Reftel wrote:
> > Currently, castring away volatile from a pointer makes -Wcast-qual
> > claim that __attribute__((noreturn)) was cast away (see bugzilla
> > 55383). The attached patch, originally written by Manuel López-Ibáñez
> > and updated to match trunk by me, correctes that. No regressions on
> > gcc from applying this patch (as reported by "make check") were seen.
> > 
> > 2014-03-11 Manuel López-Ibáñez  <manu@gcc.gnu.org>
> > 
> >  PR c/55383
> >  * c/c-typeck.c: use correct format string in cast-qual warning
> 
> I volunteer applying this if approved.

The ChangeLog is incorrect (there should be two spaces before Manuel and
no c/ prefix for the filename).

I'll defer review to Joseph or Jason.

	Jakub

Patch

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 524a59f..0bfc12b 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -4855,7 +4855,7 @@  handle_warn_cast_qual (location_t loc, tree type, tree otype)
     /* There are qualifiers present in IN_OTYPE that are not present
        in IN_TYPE.  */
     warning_at (loc, OPT_Wcast_qual,
-		"cast discards %q#v qualifier from pointer target type",
+		"cast discards %qv qualifier from pointer target type",
 		discarded);
 
   if (added || discarded)
diff --git a/gcc/testsuite/c-c++-common/Wcast-qual-1.c b/gcc/testsuite/c-c++-common/Wcast-qual-1.c
index 640e4f0..af80438 100644
--- a/gcc/testsuite/c-c++-common/Wcast-qual-1.c
+++ b/gcc/testsuite/c-c++-common/Wcast-qual-1.c
@@ -85,11 +85,11 @@  f3 (void ***bar)
 void
 f4 (void * const **bar)
 {
-  const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */
+  const void ***p9 = (const void ***) bar; /* { dg-warning "cast discards .const. qualifier " } */
   void * const **p11 = (void * const **) bar;
   void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast" } */
   const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */
-  const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */
+  const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast discards .const. qualifier" } */
   void * const * const * p19 = (void * const * const *) bar;
   const void * const * const *p21 = (const void * const * const *) bar;
 }