Mercurial > hg > CbC > CbC_gcc
annotate gcc/testsuite/c-c++-common/Wlogical-not-parentheses-1.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
rev | line source |
---|---|
111 | 1 /* PR c/77292 */ |
2 /* { dg-do compile } */ | |
3 /* { dg-options "-Wlogical-not-parentheses" } */ | |
4 | |
5 /* Test that we don't warn if rhs is a comparison or a logical op. */ | |
6 | |
7 int | |
8 foo (int a, int b) | |
9 { | |
10 int r = 0; | |
11 r += !a == (a < b); | |
12 r += !a == (a > b); | |
13 r += !a == (a >= b); | |
14 r += !a == (a <= b); | |
15 r += !a == (a != b); | |
16 r += !a == (a == b); | |
17 r += !a == (a || b); | |
18 r += !a == (a && b); | |
19 r += !a == (!b); | |
20 | |
21 r += !a == (a ^ b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ | |
22 r += !a == (a | b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ | |
23 r += !a == (a & b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ | |
24 | |
25 return r; | |
26 } |