This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wparentheses lumps too much together


On Dec 19, 2007 3:02 PM,  <jklowden@freetds.org> wrote:
> My specific candidate for exclusion from -Wall is this one:
>
>         if (a && b || c && d)
>
> which yields (as you know) advice to parenthesize the two && pairs.

To make this discussion a bit more concrete, the attached patch
removes this particular warning from -Wparentheses and puts it into a
new warning, -Wprecedence, that is not enabled by -Wall. This is
slightly more fine-grained than what -Wparentheses does now. Opinions?

  - Doug

2008-01-11  Douglas Gregor  <doug.gregor@gmail.com>

	* invoke.texi: Document Wprecedence.

2008-01-11  Douglas Gregor  <doug.gregor@gmail.com>

	* gcc.dg/Wparentheses-1.c: Use -Wprecedence
	* gcc.dg/Wparentheses-5.c: Ditto.
	* g++.dg/warn/Wparentheses-8.C: Ditto.
	* g++.dg/warn/Wparentheses-17.C: Ditto.
	* g++.dg/warn/Wparentheses-5.C: Ditto.
	
2008-01-11  Douglas Gregor  <doug.gregor@gmail.com>

	* typeck.c (build_x_binary_op): Call warn_about_parentheses if
	either warn_parentheses or warn_precedence.
	(convert_for_assignment): Ditto.

2008-01-11  Douglas Gregor  <doug.gregor@gmail.com>

	* c.opt (Wprecedence): Add new warning category.
	* c-typeck.c (parser_build_binary_op): Call warn_about_parentheses
	if either warn_parentheses or warn_precedence.
	(c-common.c): Use Wprecedence for the warning about && and ||.

Attachment: Wprecedence.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]