testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / Wlogical-op-1.c
blobc5f992a400706a105b9fabf681ab475672ce6f25
1 /* PR c/63357 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wlogical-op" } */
5 #ifndef __cplusplus
6 # define bool _Bool
7 # define true 1
8 # define false 0
9 #endif
11 #if __SIZEOF_INT__ < 4
12 __extension__ typedef __INT32_TYPE__ int32_t;
13 __extension__ typedef __UINT32_TYPE__ uint32_t;
14 __extension__ typedef __INT16_TYPE__ int16_t;
15 #else
16 typedef int int32_t;
17 typedef unsigned int uint32_t;
18 typedef short int16_t;
19 #endif
21 extern int32_t bar (void);
22 extern int32_t *p;
23 struct R { int32_t a, b; } S;
25 void
26 andfn (int32_t a, int32_t b)
28 if (a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
29 if (!a && !a) {} /* { dg-warning "logical .and. of equal expressions" } */
30 if (!!a && !!a) {} /* { dg-warning "logical .and. of equal expressions" } */
31 if (a > 0 && a > 0) {} /* { dg-warning "logical .and. of equal expressions" } */
32 if (a < 0 && a < 0) {} /* { dg-warning "logical .and. of equal expressions" } */
33 if (a == 0 && a == 0) {} /* { dg-warning "logical .and. of equal expressions" } */
34 if (a <= 0 && a <= 0) {} /* { dg-warning "logical .and. of equal expressions" } */
35 if (a >= 0 && a >= 0) {} /* { dg-warning "logical .and. of equal expressions" } */
36 if (a == 0 && !(a != 0)) {} /* { dg-warning "logical .and. of equal expressions" } */
38 if (a && a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
39 if ((a + 1) && (a + 1)) {} /* { dg-warning "logical .and. of equal expressions" } */
40 if ((10 * a) && (a * 10)) {} /* { dg-warning "logical .and. of equal expressions" } */
41 if (!!a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
43 if (*p && *p) {} /* { dg-warning "logical .and. of equal expressions" } */
44 if (p[0] && p[0]) {} /* { dg-warning "logical .and. of equal expressions" } */
45 if (S.a && S.a) {} /* { dg-warning "logical .and. of equal expressions" } */
46 if ((bool) a && (bool) a) {} /* { dg-warning "logical .and. of equal expressions" } */
47 if ((uint32_t) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
49 /* Stay quiet here. */
50 if (a && b) {}
51 if (!a && !b) {}
52 if (!!a && !!b) {}
53 if (a > 0 && b > 0) {}
54 if (a < 0 && b < 0) {}
55 if (a == 0 && b == 0) {}
56 if (a <= 0 && b <= 0) {}
57 if (a >= 0 && b >= 0) {}
59 if (a > 0 && a > 1) {}
60 if (a > -2 && a > 1) {}
61 if (a && (int16_t) a) {}
62 if ((char) a && a) {}
63 if (++a && a) {}
64 if (++a && ++a) {}
65 if (a && --a) {}
66 if (a && a / 2) {}
67 if (bar () && bar ()) {}
68 if (p && *p) {}
69 if (p[0] && p[1]) {}
70 if (S.a && S.b) {}
73 void
74 orfn (int32_t a, int32_t b)
76 if (a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
77 if (!a || !a) {} /* { dg-warning "logical .or. of equal expressions" } */
78 if (!!a || !!a) {} /* { dg-warning "logical .or. of equal expressions" } */
79 if (a > 0 || a > 0) {} /* { dg-warning "logical .or. of equal expressions" } */
80 if (a < 0 || a < 0) {} /* { dg-warning "logical .or. of equal expressions" } */
81 if (a == 0 || a == 0) {} /* { dg-warning "logical .or. of equal expressions" } */
82 if (a <= 0 || a <= 0) {} /* { dg-warning "logical .or. of equal expressions" } */
83 if (a >= 0 || a >= 0) {} /* { dg-warning "logical .or. of equal expressions" } */
84 if (a == 0 || !(a != 0)) {} /* { dg-warning "logical .or. of equal expressions" } */
86 if (a || a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
87 if ((a + 1) || (a + 1)) {} /* { dg-warning "logical .or. of equal expressions" } */
88 if ((10 * a) || (a * 10)) {} /* { dg-warning "logical .or. of equal expressions" } */
89 if (!!a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
91 if (*p || *p) {} /* { dg-warning "logical .or. of equal expressions" } */
92 if (p[0] || p[0]) {} /* { dg-warning "logical .or. of equal expressions" } */
93 if (S.a || S.a) {} /* { dg-warning "logical .or. of equal expressions" } */
94 if ((bool) a || (bool) a) {} /* { dg-warning "logical .or. of equal expressions" } */
95 if ((uint32_t) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
97 /* Stay quiet here. */
98 if (a || b) {}
99 if (!a || !b) {}
100 if (!!a || !!b) {}
101 if (a > 0 || b > 0) {}
102 if (a < 0 || b < 0) {}
103 if (a == 0 || b == 0) {}
104 if (a <= 0 || b <= 0) {}
105 if (a >= 0 || b >= 0) {}
107 if (a > 0 || a > 1) {}
108 if (a > -2 || a > 1) {}
109 if (a || (int16_t) a) {}
110 if ((char) a || a) {}
111 if (++a || a) {}
112 if (++a || ++a) {}
113 if (a || --a) {}
114 if (a || a / 2) {}
115 if (bar () || bar ()) {}
116 if (p || *p) {}
117 if (p[0] || p[1]) {}
118 if (S.a || S.b) {}