On Dec 19, 2007 3:02 PM,  <[EMAIL PROTECTED]> 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  <[EMAIL PROTECTED]>

        * invoke.texi: Document Wprecedence.

2008-01-11  Douglas Gregor  <[EMAIL PROTECTED]>

        * 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  <[EMAIL PROTECTED]>

        * 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  <[EMAIL PROTECTED]>

        * 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

Reply via email to