diff mbox

Enable -Wlogical-not-parentheses by -Wall

Message ID 20140902155311.GD30348@redhat.com
State New
Headers show

Commit Message

Marek Polacek Sept. 2, 2014, 3:53 p.m. UTC
Now that PR61271 and PR62270 have been fixed, we can enable
-Wlogical-not-parentheses by -Wall.  I think this warning proved
useful.

Bootstrapped/regtested on x86_64-linux and ppc64-linux, ok for trunk?

2014-08-26  Marek Polacek  <polacek@redhat.com>

	* doc/invoke.texi: Document that -Wlogical-not-parentheses is enabled
	by -Wall.
c-family/
	* c.opt (Wlogical-not-parentheses): Enable by -Wall.


	Marek

Comments

Jeff Law Sept. 3, 2014, 6:53 p.m. UTC | #1
On 09/02/14 09:53, Marek Polacek wrote:
> Now that PR61271 and PR62270 have been fixed, we can enable
> -Wlogical-not-parentheses by -Wall.  I think this warning proved
> useful.
>
> Bootstrapped/regtested on x86_64-linux and ppc64-linux, ok for trunk?
>
> 2014-08-26  Marek Polacek  <polacek@redhat.com>
>
> 	* doc/invoke.texi: Document that -Wlogical-not-parentheses is enabled
> 	by -Wall.
> c-family/
> 	* c.opt (Wlogical-not-parentheses): Enable by -Wall.
OK.  I'm sure this is going to trip in someone's code and they'll 
complain.  But I've always stated that warnings, particularly from 
-Wall, are not consistent from release to release.  Thus someone using 
-Wall has to be prepared to fix their code at each release because we 
can and will add things to -Wall over time.

jeff
Marek Polacek Sept. 3, 2014, 7:40 p.m. UTC | #2
On Wed, Sep 03, 2014 at 12:53:21PM -0600, Jeff Law wrote:
> On 09/02/14 09:53, Marek Polacek wrote:
> >Now that PR61271 and PR62270 have been fixed, we can enable
> >-Wlogical-not-parentheses by -Wall.  I think this warning proved
> >useful.
> >
> >Bootstrapped/regtested on x86_64-linux and ppc64-linux, ok for trunk?
> >
> >2014-08-26  Marek Polacek  <polacek@redhat.com>
> >
> >	* doc/invoke.texi: Document that -Wlogical-not-parentheses is enabled
> >	by -Wall.
> >c-family/
> >	* c.opt (Wlogical-not-parentheses): Enable by -Wall.
> OK.  I'm sure this is going to trip in someone's code and they'll complain.
> But I've always stated that warnings, particularly from -Wall, are not
> consistent from release to release.  Thus someone using -Wall has to be
> prepared to fix their code at each release because we can and will add
> things to -Wall over time.

Yeah.  Fortunately the warning shouldn't have (m)any false positives.

	Marek
diff mbox

Patch

diff --git gcc/c-family/c.opt gcc/c-family/c.opt
index 210a099..643f256 100644
--- gcc/c-family/c.opt
+++ gcc/c-family/c.opt
@@ -519,7 +519,7 @@  C ObjC C++ ObjC++ Var(warn_logical_op) Init(0) Warning
 Warn when a logical operator is suspiciously always evaluating to true or false
 
 Wlogical-not-parentheses
-C ObjC C++ ObjC++ Var(warn_logical_not_paren) Warning
+C ObjC C++ ObjC++ Var(warn_logical_not_paren) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 Warn when logical not is used on the left hand side operand of a comparison
 
 Wlong-long
diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi
index d15d4a9..9864708 100644
--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -4800,6 +4800,8 @@  parentheses:
 if ((!a) > 1) @{ @dots{} @}
 @end smallexample
 
+This warning is enabled by @option{-Wall}.
+
 @item -Waggregate-return
 @opindex Waggregate-return
 @opindex Wno-aggregate-return