Bug 35058 - -Werror= works only with some warnings
Summary: -Werror= works only with some warnings
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Manuel López-Ibáñez
URL:
Keywords:
Depends on:
Blocks: 4.4pending
  Show dependency treegraph
 
Reported: 2008-02-02 16:55 UTC by michaelni
Modified: 2008-07-23 16:00 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-02 21:15:32


Attachments
patch (1.69 KB, patch)
2008-02-03 13:36 UTC, Manuel López-Ibáñez
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description michaelni 2008-02-02 16:55:10 UTC
-Werror=declaration-after-statement and -Werror=pointer-arith
only generate warnings not errors. 
Example
-----
void *a;

void *test(){
    if(a=a) a++;
    int x=5;
    return a+x;
}
----
gcc-4.3 -Werror=declaration-after-statement -Werror=pointer-arith testX.c -c -o testX
----

adding -Werror=parentheses generates an error as expected though
also interrestingly -fdiagnostics-show-option shows only [-Wparentheses] and nothing for the other 2 warnings

Note, this issue has been seen on x86-32 and ppc
Comment 1 Manuel López-Ibáñez 2008-02-02 21:15:32 UTC
Thanks for the report.

Any warning that does not show with -fdiagnostics-show-option is very likely to not work with -Werror= and viceversa, so please report all of them that you find.
Comment 2 Manuel López-Ibáñez 2008-02-03 13:36:29 UTC
Created attachment 15084 [details]
patch

This patch fixes the problem. Testcases for this would be cumbersome but could be created if required. Are we going to test every possible combination of -W*, -Werror=* and -pedantic? I hope not.

Boostrapped and regression tested with --enable-languages=all on x86_64-unknown-linux-gnu.

I will submit as soon as GCC 4.4 is opened.
Comment 3 Manuel López-Ibáñez 2008-07-23 15:58:33 UTC
Subject: Bug 35058

Author: manu
Date: Wed Jul 23 15:57:49 2008
New Revision: 138089

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138089
Log:
2008-07-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR 35058
	* diagnostic.c (pedwarn): Add opt parameter.
	(pedwarn0): New.
	* c-tree.h (pedwarn_init): Add opt parameter.
	(pedwarn_c90): Likewise.
	(pedwarn_c99): Likewise.
	* c-errors.c (pedwarn_c99): Likewise.
	(pedwarn_c90): Likewise.
	* toplev.h (pedwarn): Update declaration.
	(pedwarn0): Declare.
	* c-lex.c: All calls to pedwarn changed.
	* builtins.c: All calls to pedwarn changed.
	* toplev.c: All calls to pedwarn changed.
	* c-decl.c: All calls to pedwarn changed.
	* c-typeck.c: All calls to pedwarn changed.
	* c-common.c: All calls to pedwarn changed.
	* c-parser.c: All calls to pedwarn changed.
cp/
	* typeck.c: All calls to pedwarn changed.
	* decl.c: All calls to pedwarn changed.
	* call.c: All calls to pedwarn changed.
	* error.c: All calls to pedwarn changed.
	* typeck2.c: All calls to pedwarn changed.
	* pt.c: All calls to pedwarn changed.
	* name-lookup.c: All calls to pedwarn changed.
	* parser.c: All calls to pedwarn changed.
fortran/
	* f95-lang.c (gfc_mark_addressable): All calls to pedwarn changed.
testsuite/
	* gcc.dg/Wdeclaration-after-statement-3.c: New.
	* gcc/testsuite/gcc.dg/Wpointer-arith.c: New.


Added:
    trunk/gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
    trunk/gcc/testsuite/gcc.dg/Wpointer-arith.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/c-common.c
    trunk/gcc/c-decl.c
    trunk/gcc/c-errors.c
    trunk/gcc/c-lex.c
    trunk/gcc/c-parser.c
    trunk/gcc/c-tree.h
    trunk/gcc/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/error.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/diagnostic.c
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/f95-lang.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/toplev.c
    trunk/gcc/toplev.h

Comment 4 Manuel López-Ibáñez 2008-07-23 16:00:49 UTC
This should be fixed in GCC 4.4. If you find any new cases please REOPEN this with a testcase.