comparison gcc/testsuite/c-c++-common/pr65120.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-do compile } */
2 /* { dg-options "-Wlogical-not-parentheses" } */
3
4 /* Test that we don't warn if rhs is 0 and comparison is == or !=. */
5
6 #ifndef __cplusplus
7 #define bool _Bool
8 #endif
9
10 bool r;
11
12 int
13 f1 (int a)
14 {
15 r = !a == 0;
16 r = !a != 0;
17 r = !a == 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
18 r = !a != 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
19 }
20
21 int
22 f2 (int a)
23 {
24 r = !a > 0; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
25 r = !a >= 0; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
26 r = !a < 0; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
27 r = !a <= 0; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
28 r = !a > 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
29 r = !a >= 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
30 r = !a < 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
31 r = !a <= 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
32 }