-Wparentheses lumps too much together

Doug Gregor doug.gregor@gmail.com
Fri Jan 11 22:44:00 GMT 2008


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 ||.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Wprecedence.patch
Type: application/octet-stream
Size: 6897 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20080111/a9098d14/attachment.obj>


More information about the Gcc mailing list