This is the mail archive of the gcc-bugs@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]

[Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896

Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #5 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-04-26 22:23:59 UTC ---
manuel@gcc12:~$ clang -Wextra -Wall -Weverything -fsyntax-only pr17896.c
pr17896.c:4:1: warning: no previous prototype for function 'bar'
[-Wmissing-prototypes]
bar (int a, int b, int c)
^
pr17896.c:7:17: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
    foo (a == b & (b == c));   /* { dg-warning "boolean" "correct warning" } */
         ~~~~~~~^
pr17896.c:7:17: note: place parentheses around the == expression to silence
this warning
    foo (a == b & (b == c));   /* { dg-warning "boolean" "correct warning" } */
                ^
                  (       )
pr17896.c:7:17: note: place parentheses around the & expression to evaluate it
first
    foo (a == b & (b == c));   /* { dg-warning "boolean" "correct warning" } */
                ^
              (           )
pr17896.c:8:19: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
    foo ((a == b) & b == c);   /* { dg-warning "boolean" "correct warning" } */
                  ^~~~~~~~
pr17896.c:8:19: note: place parentheses around the == expression to silence
this warning
    foo ((a == b) & b == c);   /* { dg-warning "boolean" "correct warning" } */
                  ^
                    (     )
pr17896.c:8:19: note: place parentheses around the & expression to evaluate it
first
    foo ((a == b) & b == c);   /* { dg-warning "boolean" "correct warning" } */
                  ^
         (           )
pr17896.c:13:16: warning: | has lower precedence than ==; == will be evaluated
first [-Wparentheses]
   foo (a == b | (b == c));   /* { dg-warning "boolean" "correct warning" } */
        ~~~~~~~^
pr17896.c:13:16: note: place parentheses around the == expression to silence
this warning
   foo (a == b | (b == c));   /* { dg-warning "boolean" "correct warning" } */
               ^
                 (       )
pr17896.c:13:16: note: place parentheses around the | expression to evaluate it
first
   foo (a == b | (b == c));   /* { dg-warning "boolean" "correct warning" } */
               ^
             (           )
pr17896.c:14:18: warning: | has lower precedence than ==; == will be evaluated
first [-Wparentheses]
   foo ((a == b) | b == c);   /* { dg-warning "boolean" "correct warning" } */
                 ^~~~~~~~
pr17896.c:14:18: note: place parentheses around the == expression to silence
this warning
   foo ((a == b) | b == c);   /* { dg-warning "boolean" "correct warning" } */
                 ^
                   (     )
pr17896.c:14:18: note: place parentheses around the | expression to evaluate it
first
   foo ((a == b) | b == c);   /* { dg-warning "boolean" "correct warning" } */
                 ^
        (           )
5 warnings generated.


manuel@gcc12:~$ ~/trunk/186353/build/gcc/cc1 -Wextra -Wall -Wlogical-op
-fsyntax-only pr17896.c 
 bar
pr17896.c: In function âbarâ:
pr17896.c:6:5: warning: suggest parentheses around comparison in operand of â&â
[-Wparentheses]
     foo (a == b & b == c);     /* { dg-warning "boolean" "correct warning" }
*/
     ^
pr17896.c:7:5: warning: suggest parentheses around comparison in operand of â&â
[-Wparentheses]
     foo (a == b & (b == c));   /* { dg-warning "boolean" "correct warning" }
*/
     ^
pr17896.c:8:5: warning: suggest parentheses around comparison in operand of â&â
[-Wparentheses]
     foo ((a == b) & b == c);   /* { dg-warning "boolean" "correct warning" }
*/
     ^
pr17896.c:9:5: warning: suggest parentheses around comparison in operand of â&â
[-Wparentheses]
     foo (++a == b & b == c);   /* { dg-warning "comparison" "correct warning"
} */
     ^
pr17896.c:12:5: warning: suggest parentheses around comparison in operand of
â|â [-Wparentheses]
     foo (a == b | b == c);     /* { dg-warning "boolean" "correct warning" }
*/
     ^
pr17896.c:13:4: warning: suggest parentheses around comparison in operand of
â|â [-Wparentheses]
    foo (a == b | (b == c));   /* { dg-warning "boolean" "correct warning" } */
    ^
pr17896.c:14:4: warning: suggest parentheses around comparison in operand of
â|â [-Wparentheses]
    foo ((a == b) | b == c);   /* { dg-warning "boolean" "correct warning" } */
    ^
pr17896.c:15:4: warning: suggest parentheses around comparison in operand of
â|â [-Wparentheses]
    foo (++a == b | b == c);   /* { dg-warning "comparison" "correct warning" }
*/
    ^


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