[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #17 from Manuel López-Ibáñez  ---
Author: manu
Date: Tue Mar 18 23:22:02 2014
New Revision: 208669

URL: http://gcc.gnu.org/viewcvs?rev=208669&root=gcc&view=rev
Log:
2014-03-19  Manuel López-Ibáñez  

PR c/55383
* gcc.dg/cast-qual-3.c: New.
Revert:
2014-03-18  Manuel López-Ibáñez  
* c-c++-common/Wcast-qual-1.c: More precise match text.

Added:
trunk/gcc/testsuite/gcc.dg/cast-qual-3.c
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/c-c++-common/Wcast-qual-1.c

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #16 from Manuel López-Ibáñez  ---
It seems the patch was not tested in C++:

Tests that now fail, but worked before:

unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++11  (test for warnings, line
88)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++11  (test for warnings, line
92)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++11 (test for excess errors)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++1y  (test for warnings, line
88)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++1y  (test for warnings, line
92)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++1y (test for excess errors)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++98  (test for warnings, line
88)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++98  (test for warnings, line
92)
unix//-m32: c-c++-common/Wcast-qual-1.c -std=gnu++98 (test for excess errors)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++11  (test for warnings, line
88)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++11  (test for warnings, line
92)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++11 (test for excess errors)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++1y  (test for warnings, line
88)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++1y  (test for warnings, line
92)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++1y (test for excess errors)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++98  (test for warnings, line
88)
unix//-m64: c-c++-common/Wcast-qual-1.c -std=gnu++98  (test for warnings, line
92)

I guess my patch should have not touched an already existing testcase but
instead add a new one for C only.

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

Manuel López-Ibáñez  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from Manuel López-Ibáñez  ---
Of course, the bug affects all qualifiers, not just volatile, so the updated
testcase would be enough to catch this in case we regress. So I went ahead and
committed the patch. This will be fixed in GCC 4.9. For earlier versions,
you'll have to ask Jakub or Joseph in the mailing list about backporting the
patch, since it is not technically a regression but it is a trivial fix. Unless
someone steps up to take care of backporting, I'd consider this FIXED.

Thanks Magnus for following up on this. I know some other bugs with patches in
case you are interested (and plenty of trivial bugs without a patch!).

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #14 from Manuel López-Ibáñez  ---
Author: manu
Date: Tue Mar 18 19:58:39 2014
New Revision: 208661

URL: http://gcc.gnu.org/viewcvs?rev=208661&root=gcc&view=rev
Log:
2014-03-18  Manuel López-Ibáñez  

PR c/55383
c/
* c-typeck.c: Use correct format string in cast-qual warning
testsuite/
* c-c++-common/Wcast-qual-1.c: More precise match text.

Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/c-c++-common/Wcast-qual-1.c

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #13 from Manuel López-Ibáñez  ---
(In reply to Magnus Reftel from comment #12)
> Any suggestions on how to progress with this one?

Looking at the testcases modified by the patch, I don't know why there is no
test for volatile (which is what triggers this bug). I will take a look at the
output of the testsuite this weekend. It is probable that there is a testcase
for this, but the test matching text is not precise enough. Once I check this,
I will commit the patch since it was approved by Joseph here:

http://gcc.gnu.org/ml/gcc-patches/2014-03/msg00532.html

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-18 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #12 from Magnus Reftel  ---
Any suggestions on how to progress with this one?


[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-11 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #11 from Magnus Reftel  ---
No regressions seen. Sent en email with the patch to gcc-patches as requested (
http://gcc.gnu.org/ml/gcc-patches/2014-03/msg00517.html ).


[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-11 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #10 from Magnus Reftel  ---
Applied Manuel López-Ibáñez's patch on top of trunk and tested Jeremy's
testcase. Without the patch, the error message says that
"__attribute__((noreturn))" is being cast away. With the patch, the error
message says that "volatile" is being cast away. Running "make check" to see if
there were any regressions.

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #9 from Magnus Reftel  ---
Created attachment 32331
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32331&action=edit
Patch from comment #1, updated to apply on trunk


[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread gerald at pfeifer dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

Gerald Pfeifer  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #8 from Gerald Pfeifer  ---
I'll see what I can do.


[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

Manuel López-Ibáñez  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #7 from Manuel López-Ibáñez  ---
(In reply to Magnus Reftel from comment #6)
> Sorry, I'm not a GCC developer - just another user aflicted by the bug.

Everybody can be a GCC developer. You don't need special powers, just some free
time and willing to be. For such a small patch, you don't need any copyright
assignment. Just check out svn trunk, set up a bootstrap, test without the
patch, apply the patch, bootstrap and test with the patch and compare the
results. (Check the gccfarming script here:
http://gcc.gnu.org/wiki/ManuelL%C3%B3pezIb%C3%A1%C3%B1ez for all the details).

If the patch does not produce any new FAILs in the testsuite, submit to
gcc-patches with a changelog and ask the reviewer to commit it once accepted.

(You don't even need a powerful computer to do all this, just get an account on
the compile farm: http://gcc.gnu.org/wiki/CompileFarm )

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #6 from Magnus Reftel  ---
Sorry, I'm not a GCC developer - just another user aflicted by the bug.


[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #5 from Manuel López-Ibáñez  ---
(In reply to Magnus Reftel from comment #4)
> Also affects 4.6, 4.8 and trunk as of version
> 96c7d4b1727c5f9ddcbb02fb69f727a0f2f3572e. 4.4 correctly prints just "error:
> cast discards qualifiers from pointer target type". Did not check with
> version 4.5.
> 
> Since 4.4 had it right, does this count as a 4.6/4.7/4.8/4.9 regression?

This just needs someone willing to test the patch in comment #1 and submit it.
It is such a trivial patch that I cannot claim any authorship, so please adopt
it and get it fixed. If you are fast enough, you may be able to sneak it in GCC
4.9. (The time it took you to do all those tests would have been better spent
fixing the bug.)

[Bug c/55383] -Wcast-qual reports incorrect message

2014-03-10 Thread magnus.reftel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

Magnus Reftel  changed:

   What|Removed |Added

 CC||magnus.reftel at gmail dot com

--- Comment #4 from Magnus Reftel  ---
Also affects 4.6, 4.8 and trunk as of version
96c7d4b1727c5f9ddcbb02fb69f727a0f2f3572e. 4.4 correctly prints just "error:
cast discards qualifiers from pointer target type". Did not check with version
4.5.

Since 4.4 had it right, does this count as a 4.6/4.7/4.8/4.9 regression?


[Bug c/55383] -Wcast-qual reports incorrect message

2013-06-08 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #3 from Manuel López-Ibáñez  ---
(In reply to Gerald Pfeifer from comment #2)
> Somehow I cannot find your patch submission on gcc-patches -- is it
> possible you haven't submitted it there yet?  Will you be doing that,
> or is it fine if I do?

I don't remember what happened with this patch. Please feel free to adopt it if
it works. Thanks for taking care of it.

[Bug c/55383] -Wcast-qual reports incorrect message

2013-06-08 Thread gerald at pfeifer dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

--- Comment #2 from Gerald Pfeifer  ---
Hi Manuel, I also got pinged by a FreeBSD user of one of my ports
about this.

Somehow I cannot find your patch submission on gcc-patches -- is it
possible you haven't submitted it there yet?  Will you be doing that,
or is it fine if I do?


[Bug c/55383] -Wcast-qual reports incorrect message

2012-11-18 Thread manu at gcc dot gnu.org

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383

Manuel López-Ibáñez  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-11-18
 CC||manu at gcc dot gnu.org
 Ever Confirmed|0   |1

--- Comment #1 from Manuel López-Ibáñez  2012-11-18 
21:15:09 UTC ---
Confirmed. The warning call is wrong:

c/c-typeck.c-4468-/* There are qualifiers present in IN_OTYPE that are not
present
c/c-typeck.c-4469-   in IN_TYPE.  */
c/c-typeck.c-4470-warning_at (loc, OPT_Wcast_qual,
c/c-typeck.c:4471:  "cast discards %q#v qualifier from pointer
target type",
c/c-typeck.c-4472-  discarded);
c/c-typeck.c-4473-
c/c-typeck.c-4474-  if (added || discarded)

It should use %qv for non-function types. Patch:


Index: c/c-typeck.c
===
--- c/c-typeck.c(revision 192847)
+++ c/c-typeck.c(working copy)
@@ -4466,11 +4466,11 @@ handle_warn_cast_qual (location_t loc, t

   if (discarded)
 /* 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)
 return;

Index: testsuite/c-c++-common/Wcast-qual-1.c
===
--- testsuite/c-c++-common/Wcast-qual-1.c   (revision 192847)
+++ testsuite/c-c++-common/Wcast-qual-1.c   (working copy)
@@ -83,15 +83,15 @@ 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" } */
+  void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast discards
.const. qualifier" } */
   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;
 }