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

login
register
mail settings
Submitter Magnus Reftel
Date March 11, 2014, 12:46 p.m.
Message ID <CABqVM5Fb3qjj2iMWdvV+LQiJtGbam+LQToukwXCQV=dy613mtw@mail.gmail.com>
Download mbox | patch
Permalink /patch/329073/
State New
Headers show

Comments

Magnus Reftel - March 11, 2014, 12:46 p.m.
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.

BR
Magnus Reftel

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

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;
 }