xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/identical-expressions.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.IdenticalExpr -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc /* Only one expected warning per function allowed at the very end. */
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc /* '!=' operator*/
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc /* '!=' with float */
8*f4a2713aSLionel Sambuc int checkNotEqualFloatLiteralCompare1(void) {
9*f4a2713aSLionel Sambuc   return (5.14F != 5.14F); // no warning
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc int checkNotEqualFloatLiteralCompare2(void) {
13*f4a2713aSLionel Sambuc   return (6.14F != 7.14F); // no warning
14*f4a2713aSLionel Sambuc }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare1(void) {
17*f4a2713aSLionel Sambuc   float f = 7.1F;
18*f4a2713aSLionel Sambuc   float g = 7.1F;
19*f4a2713aSLionel Sambuc   return (f != g); // no warning
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare12(void) {
23*f4a2713aSLionel Sambuc   float f = 7.1F;
24*f4a2713aSLionel Sambuc   return (f != f); // no warning
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare3(void) {
28*f4a2713aSLionel Sambuc   float f = 7.1F;
29*f4a2713aSLionel Sambuc   return (f != 7.1F); // no warning
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare4(void) {
33*f4a2713aSLionel Sambuc   float f = 7.1F;
34*f4a2713aSLionel Sambuc   return (7.1F != f); // no warning
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare5(void) {
38*f4a2713aSLionel Sambuc   float f = 7.1F;
39*f4a2713aSLionel Sambuc   int t = 7;
40*f4a2713aSLionel Sambuc   return (t != f); // no warning
41*f4a2713aSLionel Sambuc }
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc int checkNotEqualFloatDeclCompare6(void) {
44*f4a2713aSLionel Sambuc   float f = 7.1F;
45*f4a2713aSLionel Sambuc   int t = 7;
46*f4a2713aSLionel Sambuc   return (f != t); // no warning
47*f4a2713aSLionel Sambuc }
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc int checkNotEqualCastFloatDeclCompare11(void) {
52*f4a2713aSLionel Sambuc   float f = 7.1F;
53*f4a2713aSLionel Sambuc   return ((int)f != (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
54*f4a2713aSLionel Sambuc }
55*f4a2713aSLionel Sambuc int checkNotEqualCastFloatDeclCompare12(void) {
56*f4a2713aSLionel Sambuc   float f = 7.1F;
57*f4a2713aSLionel Sambuc   return ((char)f != (int)f); // no warning
58*f4a2713aSLionel Sambuc }
59*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpFloatCompare1(void) {
60*f4a2713aSLionel Sambuc   int res;
61*f4a2713aSLionel Sambuc   float f= 3.14F;
62*f4a2713aSLionel Sambuc   res = (f + 3.14F != f + 3.14F);  // no warning
63*f4a2713aSLionel Sambuc   return (0);
64*f4a2713aSLionel Sambuc }
65*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpFloatCompare2(void) {
66*f4a2713aSLionel Sambuc   float f = 7.1F;
67*f4a2713aSLionel Sambuc   float g = 7.1F;
68*f4a2713aSLionel Sambuc   return (f + 3.14F != g + 3.14F); // no warning
69*f4a2713aSLionel Sambuc }
70*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpFloatCompare3(void) {
71*f4a2713aSLionel Sambuc   int res;
72*f4a2713aSLionel Sambuc   float f= 3.14F;
73*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F != (int)f + 3.14F);  // no warning
74*f4a2713aSLionel Sambuc   return (0);
75*f4a2713aSLionel Sambuc }
76*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpFloatCompare4(void) {
77*f4a2713aSLionel Sambuc   int res;
78*f4a2713aSLionel Sambuc   float f= 3.14F;
79*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F != (char)f + 3.14F);  // no warning
80*f4a2713aSLionel Sambuc   return (0);
81*f4a2713aSLionel Sambuc }
82*f4a2713aSLionel Sambuc 
83*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpFloatCompare1(void) {
84*f4a2713aSLionel Sambuc   int res;
85*f4a2713aSLionel Sambuc   int t= 1;
86*f4a2713aSLionel Sambuc   int u= 2;
87*f4a2713aSLionel Sambuc   float f= 3.14F;
88*f4a2713aSLionel Sambuc   res = (((int)f + (3.14F - u)*t) != ((int)f + (3.14F - u)*t));  // no warning
89*f4a2713aSLionel Sambuc   return (0);
90*f4a2713aSLionel Sambuc }
91*f4a2713aSLionel Sambuc 
92*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpFloatCompare2(void) {
93*f4a2713aSLionel Sambuc   int res;
94*f4a2713aSLionel Sambuc   int t= 1;
95*f4a2713aSLionel Sambuc   int u= 2;
96*f4a2713aSLionel Sambuc   float f= 3.14F;
97*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) != ((int)f + (3.14F - u)*t));  // no warning
98*f4a2713aSLionel Sambuc   return (0);
99*f4a2713aSLionel Sambuc }
100*f4a2713aSLionel Sambuc 
101*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpFloatCompare3(void) {
102*f4a2713aSLionel Sambuc   int res;
103*f4a2713aSLionel Sambuc   int t= 1;
104*f4a2713aSLionel Sambuc   int u= 2;
105*f4a2713aSLionel Sambuc   float f= 3.14F;
106*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) != ((int)f + (3.14F - u)*(f + t != f + t)));  // no warning
107*f4a2713aSLionel Sambuc   return (0);
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc 
110*f4a2713aSLionel Sambuc 
111*f4a2713aSLionel Sambuc 
112*f4a2713aSLionel Sambuc 
113*f4a2713aSLionel Sambuc /* end '!=' with float*/
114*f4a2713aSLionel Sambuc 
115*f4a2713aSLionel Sambuc /* '!=' with int*/
116*f4a2713aSLionel Sambuc 
117*f4a2713aSLionel Sambuc int checkNotEqualIntLiteralCompare1(void) {
118*f4a2713aSLionel Sambuc   return (5 != 5); // expected-warning {{comparison of identical expressions always evaluates to false}}
119*f4a2713aSLionel Sambuc }
120*f4a2713aSLionel Sambuc 
121*f4a2713aSLionel Sambuc int checkNotEqualIntLiteralCompare2(void) {
122*f4a2713aSLionel Sambuc   return (6 != 7); // no warning
123*f4a2713aSLionel Sambuc }
124*f4a2713aSLionel Sambuc 
125*f4a2713aSLionel Sambuc int checkNotEqualIntDeclCompare1(void) {
126*f4a2713aSLionel Sambuc   int f = 7;
127*f4a2713aSLionel Sambuc   int g = 7;
128*f4a2713aSLionel Sambuc   return (f != g); // no warning
129*f4a2713aSLionel Sambuc }
130*f4a2713aSLionel Sambuc 
131*f4a2713aSLionel Sambuc int checkNotEqualIntDeclCompare3(void) {
132*f4a2713aSLionel Sambuc   int f = 7;
133*f4a2713aSLionel Sambuc   return (f != 7); // no warning
134*f4a2713aSLionel Sambuc }
135*f4a2713aSLionel Sambuc 
136*f4a2713aSLionel Sambuc int checkNotEqualIntDeclCompare4(void) {
137*f4a2713aSLionel Sambuc   int f = 7;
138*f4a2713aSLionel Sambuc   return (7 != f); // no warning
139*f4a2713aSLionel Sambuc }
140*f4a2713aSLionel Sambuc 
141*f4a2713aSLionel Sambuc int checkNotEqualCastIntDeclCompare11(void) {
142*f4a2713aSLionel Sambuc   int f = 7;
143*f4a2713aSLionel Sambuc   return ((int)f != (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
144*f4a2713aSLionel Sambuc }
145*f4a2713aSLionel Sambuc int checkNotEqualCastIntDeclCompare12(void) {
146*f4a2713aSLionel Sambuc   int f = 7;
147*f4a2713aSLionel Sambuc   return ((char)f != (int)f); // no warning
148*f4a2713aSLionel Sambuc }
149*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntCompare1(void) {
150*f4a2713aSLionel Sambuc   int res;
151*f4a2713aSLionel Sambuc   int t= 1;
152*f4a2713aSLionel Sambuc   int u= 2;
153*f4a2713aSLionel Sambuc   int f= 4;
154*f4a2713aSLionel Sambuc   res = (f + 4 != f + 4);  // expected-warning {{comparison of identical expressions always evaluates to false}}
155*f4a2713aSLionel Sambuc   return (0);
156*f4a2713aSLionel Sambuc }
157*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntCompare2(void) {
158*f4a2713aSLionel Sambuc   int f = 7;
159*f4a2713aSLionel Sambuc   int g = 7;
160*f4a2713aSLionel Sambuc   return (f + 4 != g + 4); // no warning
161*f4a2713aSLionel Sambuc }
162*f4a2713aSLionel Sambuc 
163*f4a2713aSLionel Sambuc 
164*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntCompare3(void) {
165*f4a2713aSLionel Sambuc   int res;
166*f4a2713aSLionel Sambuc   int t= 1;
167*f4a2713aSLionel Sambuc   int u= 2;
168*f4a2713aSLionel Sambuc   int f= 4;
169*f4a2713aSLionel Sambuc   res = ((int)f + 4 != (int)f + 4);  // expected-warning {{comparison of identical expressions always evaluates to false}}
170*f4a2713aSLionel Sambuc   return (0);
171*f4a2713aSLionel Sambuc }
172*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntCompare4(void) {
173*f4a2713aSLionel Sambuc   int res;
174*f4a2713aSLionel Sambuc   int t= 1;
175*f4a2713aSLionel Sambuc   int u= 2;
176*f4a2713aSLionel Sambuc   int f= 4;
177*f4a2713aSLionel Sambuc   res = ((int)f + 4 != (char)f + 4);  // no warning
178*f4a2713aSLionel Sambuc   return (0);
179*f4a2713aSLionel Sambuc }
180*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntCompare5(void) {
181*f4a2713aSLionel Sambuc   int res;
182*f4a2713aSLionel Sambuc   int t= 1;
183*f4a2713aSLionel Sambuc   int u= 2;
184*f4a2713aSLionel Sambuc   res = (u + t != u + t);  // expected-warning {{comparison of identical expressions always evaluates to false}}
185*f4a2713aSLionel Sambuc   return (0);
186*f4a2713aSLionel Sambuc }
187*f4a2713aSLionel Sambuc 
188*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpIntCompare1(void) {
189*f4a2713aSLionel Sambuc   int res;
190*f4a2713aSLionel Sambuc   int t= 1;
191*f4a2713aSLionel Sambuc   int u= 2;
192*f4a2713aSLionel Sambuc   int f= 3;
193*f4a2713aSLionel Sambuc   res = (((int)f + (3 - u)*t) != ((int)f + (3 - u)*t));  // expected-warning {{comparison of identical expressions always evaluates to false}}
194*f4a2713aSLionel Sambuc   return (0);
195*f4a2713aSLionel Sambuc }
196*f4a2713aSLionel Sambuc 
197*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpIntCompare2(void) {
198*f4a2713aSLionel Sambuc   int res;
199*f4a2713aSLionel Sambuc   int t= 1;
200*f4a2713aSLionel Sambuc   int u= 2;
201*f4a2713aSLionel Sambuc   int f= 3;
202*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) != ((int)f + (3 - u)*t));  // no warning
203*f4a2713aSLionel Sambuc   return (0);
204*f4a2713aSLionel Sambuc }
205*f4a2713aSLionel Sambuc 
206*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpIntCompare3(void) {
207*f4a2713aSLionel Sambuc   int res;
208*f4a2713aSLionel Sambuc   int t= 1;
209*f4a2713aSLionel Sambuc   int u= 2;
210*f4a2713aSLionel Sambuc   int f= 3;
211*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) != ((int)f + (3 - u)*(t + 1 != t + 1)));  // expected-warning {{comparison of identical expressions always evaluates to false}}
212*f4a2713aSLionel Sambuc   return (0);
213*f4a2713aSLionel Sambuc }
214*f4a2713aSLionel Sambuc 
215*f4a2713aSLionel Sambuc /*   end '!=' int          */
216*f4a2713aSLionel Sambuc 
217*f4a2713aSLionel Sambuc 
218*f4a2713aSLionel Sambuc 
219*f4a2713aSLionel Sambuc /* '!=' with int pointer */
220*f4a2713aSLionel Sambuc 
221*f4a2713aSLionel Sambuc int checkNotEqualIntPointerLiteralCompare1(void) {
222*f4a2713aSLionel Sambuc   int* p = 0;
223*f4a2713aSLionel Sambuc   return (p != 0); // no warning
224*f4a2713aSLionel Sambuc }
225*f4a2713aSLionel Sambuc 
226*f4a2713aSLionel Sambuc int checkNotEqualIntPointerLiteralCompare2(void) {
227*f4a2713aSLionel Sambuc   return (6 != 7); // no warning
228*f4a2713aSLionel Sambuc }
229*f4a2713aSLionel Sambuc 
230*f4a2713aSLionel Sambuc int checkNotEqualIntPointerDeclCompare1(void) {
231*f4a2713aSLionel Sambuc   int k = 3;
232*f4a2713aSLionel Sambuc   int* f = &k;
233*f4a2713aSLionel Sambuc   int* g = &k;
234*f4a2713aSLionel Sambuc   return (f != g); // no warning
235*f4a2713aSLionel Sambuc }
236*f4a2713aSLionel Sambuc 
237*f4a2713aSLionel Sambuc int checkNotEqualCastIntPointerDeclCompare11(void) {
238*f4a2713aSLionel Sambuc   int k = 7;
239*f4a2713aSLionel Sambuc   int* f = &k;
240*f4a2713aSLionel Sambuc   return ((int*)f != (int*)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
241*f4a2713aSLionel Sambuc }
242*f4a2713aSLionel Sambuc int checkNotEqualCastIntPointerDeclCompare12(void) {
243*f4a2713aSLionel Sambuc   int k = 7;
244*f4a2713aSLionel Sambuc   int* f = &k;
245*f4a2713aSLionel Sambuc   return ((int*)((char*)f) != (int*)f); // no warning
246*f4a2713aSLionel Sambuc }
247*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntPointerCompare1(void) {
248*f4a2713aSLionel Sambuc   int k = 7;
249*f4a2713aSLionel Sambuc   int res;
250*f4a2713aSLionel Sambuc   int* f= &k;
251*f4a2713aSLionel Sambuc   res = (f + 4 != f + 4);  // expected-warning {{comparison of identical expressions always evaluates to false}}
252*f4a2713aSLionel Sambuc   return (0);
253*f4a2713aSLionel Sambuc }
254*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntPointerCompare2(void) {
255*f4a2713aSLionel Sambuc   int k = 7;
256*f4a2713aSLionel Sambuc   int* f = &k;
257*f4a2713aSLionel Sambuc   int* g = &k;
258*f4a2713aSLionel Sambuc   return (f + 4 != g + 4); // no warning
259*f4a2713aSLionel Sambuc }
260*f4a2713aSLionel Sambuc 
261*f4a2713aSLionel Sambuc 
262*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntPointerCompare3(void) {
263*f4a2713aSLionel Sambuc   int k = 7;
264*f4a2713aSLionel Sambuc   int res;
265*f4a2713aSLionel Sambuc   int* f= &k;
266*f4a2713aSLionel Sambuc   res = ((int*)f + 4 != (int*)f + 4);  // expected-warning {{comparison of identical expressions always evaluates to false}}
267*f4a2713aSLionel Sambuc   return (0);
268*f4a2713aSLionel Sambuc }
269*f4a2713aSLionel Sambuc int checkNotEqualBinaryOpIntPointerCompare4(void) {
270*f4a2713aSLionel Sambuc   int k = 7;
271*f4a2713aSLionel Sambuc   int res;
272*f4a2713aSLionel Sambuc   int* f= &k;
273*f4a2713aSLionel Sambuc   res = ((int*)f + 4 != (int*)((char*)f) + 4);  // no warning
274*f4a2713aSLionel Sambuc   return (0);
275*f4a2713aSLionel Sambuc }
276*f4a2713aSLionel Sambuc 
277*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpIntPointerCompare1(void) {
278*f4a2713aSLionel Sambuc   int res;
279*f4a2713aSLionel Sambuc   int k = 7;
280*f4a2713aSLionel Sambuc   int t= 1;
281*f4a2713aSLionel Sambuc   int* u= &k+2;
282*f4a2713aSLionel Sambuc   int* f= &k+3;
283*f4a2713aSLionel Sambuc   res = ((f + (3)*t) != (f + (3)*t));  // expected-warning {{comparison of identical expressions always evaluates to false}}
284*f4a2713aSLionel Sambuc   return (0);
285*f4a2713aSLionel Sambuc }
286*f4a2713aSLionel Sambuc 
287*f4a2713aSLionel Sambuc int checkNotEqualNestedBinaryOpIntPointerCompare2(void) {
288*f4a2713aSLionel Sambuc   int res;
289*f4a2713aSLionel Sambuc   int k = 7;
290*f4a2713aSLionel Sambuc   int t= 1;
291*f4a2713aSLionel Sambuc   int* u= &k+2;
292*f4a2713aSLionel Sambuc   int* f= &k+3;
293*f4a2713aSLionel Sambuc   res = (((3)*t + f) != (f + (3)*t));  // no warning
294*f4a2713aSLionel Sambuc   return (0);
295*f4a2713aSLionel Sambuc }
296*f4a2713aSLionel Sambuc /*   end '!=' int*          */
297*f4a2713aSLionel Sambuc 
298*f4a2713aSLionel Sambuc /*   end '!=' */
299*f4a2713aSLionel Sambuc 
300*f4a2713aSLionel Sambuc 
301*f4a2713aSLionel Sambuc 
302*f4a2713aSLionel Sambuc /* EQ operator           */
303*f4a2713aSLionel Sambuc 
304*f4a2713aSLionel Sambuc int checkEqualIntPointerDeclCompare(void) {
305*f4a2713aSLionel Sambuc   int k = 3;
306*f4a2713aSLionel Sambuc   int* f = &k;
307*f4a2713aSLionel Sambuc   int* g = &k;
308*f4a2713aSLionel Sambuc   return (f == g); // no warning
309*f4a2713aSLionel Sambuc }
310*f4a2713aSLionel Sambuc 
311*f4a2713aSLionel Sambuc int checkEqualIntPointerDeclCompare0(void) {
312*f4a2713aSLionel Sambuc   int k = 3;
313*f4a2713aSLionel Sambuc   int* f = &k;
314*f4a2713aSLionel Sambuc   return (f+1 == f+1); // expected-warning {{comparison of identical expressions always evaluates to true}}
315*f4a2713aSLionel Sambuc }
316*f4a2713aSLionel Sambuc 
317*f4a2713aSLionel Sambuc /* EQ with float*/
318*f4a2713aSLionel Sambuc 
319*f4a2713aSLionel Sambuc int checkEqualFloatLiteralCompare1(void) {
320*f4a2713aSLionel Sambuc   return (5.14F == 5.14F); // no warning
321*f4a2713aSLionel Sambuc }
322*f4a2713aSLionel Sambuc 
323*f4a2713aSLionel Sambuc int checkEqualFloatLiteralCompare2(void) {
324*f4a2713aSLionel Sambuc   return (6.14F == 7.14F); // no warning
325*f4a2713aSLionel Sambuc }
326*f4a2713aSLionel Sambuc 
327*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare1(void) {
328*f4a2713aSLionel Sambuc   float f = 7.1F;
329*f4a2713aSLionel Sambuc   float g = 7.1F;
330*f4a2713aSLionel Sambuc   return (f == g); // no warning
331*f4a2713aSLionel Sambuc }
332*f4a2713aSLionel Sambuc 
333*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare12(void) {
334*f4a2713aSLionel Sambuc   float f = 7.1F;
335*f4a2713aSLionel Sambuc   return (f == f); // no warning
336*f4a2713aSLionel Sambuc }
337*f4a2713aSLionel Sambuc 
338*f4a2713aSLionel Sambuc 
339*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare3(void) {
340*f4a2713aSLionel Sambuc   float f = 7.1F;
341*f4a2713aSLionel Sambuc   return (f == 7.1F); // no warning
342*f4a2713aSLionel Sambuc }
343*f4a2713aSLionel Sambuc 
344*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare4(void) {
345*f4a2713aSLionel Sambuc   float f = 7.1F;
346*f4a2713aSLionel Sambuc   return (7.1F == f); // no warning
347*f4a2713aSLionel Sambuc }
348*f4a2713aSLionel Sambuc 
349*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare5(void) {
350*f4a2713aSLionel Sambuc   float f = 7.1F;
351*f4a2713aSLionel Sambuc   int t = 7;
352*f4a2713aSLionel Sambuc   return (t == f); // no warning
353*f4a2713aSLionel Sambuc }
354*f4a2713aSLionel Sambuc 
355*f4a2713aSLionel Sambuc int checkEqualFloatDeclCompare6(void) {
356*f4a2713aSLionel Sambuc   float f = 7.1F;
357*f4a2713aSLionel Sambuc   int t = 7;
358*f4a2713aSLionel Sambuc   return (f == t); // no warning
359*f4a2713aSLionel Sambuc }
360*f4a2713aSLionel Sambuc 
361*f4a2713aSLionel Sambuc 
362*f4a2713aSLionel Sambuc 
363*f4a2713aSLionel Sambuc 
364*f4a2713aSLionel Sambuc int checkEqualCastFloatDeclCompare11(void) {
365*f4a2713aSLionel Sambuc   float f = 7.1F;
366*f4a2713aSLionel Sambuc   return ((int)f == (int)f); // expected-warning {{comparison of identical expressions always evaluates to true}}
367*f4a2713aSLionel Sambuc }
368*f4a2713aSLionel Sambuc int checkEqualCastFloatDeclCompare12(void) {
369*f4a2713aSLionel Sambuc   float f = 7.1F;
370*f4a2713aSLionel Sambuc   return ((char)f == (int)f); // no warning
371*f4a2713aSLionel Sambuc }
372*f4a2713aSLionel Sambuc int checkEqualBinaryOpFloatCompare1(void) {
373*f4a2713aSLionel Sambuc   int res;
374*f4a2713aSLionel Sambuc   float f= 3.14F;
375*f4a2713aSLionel Sambuc   res = (f + 3.14F == f + 3.14F);  // no warning
376*f4a2713aSLionel Sambuc   return (0);
377*f4a2713aSLionel Sambuc }
378*f4a2713aSLionel Sambuc int checkEqualBinaryOpFloatCompare2(void) {
379*f4a2713aSLionel Sambuc   float f = 7.1F;
380*f4a2713aSLionel Sambuc   float g = 7.1F;
381*f4a2713aSLionel Sambuc   return (f + 3.14F == g + 3.14F); // no warning
382*f4a2713aSLionel Sambuc }
383*f4a2713aSLionel Sambuc int checkEqualBinaryOpFloatCompare3(void) {
384*f4a2713aSLionel Sambuc   int res;
385*f4a2713aSLionel Sambuc   float f= 3.14F;
386*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F == (int)f + 3.14F);  // no warning
387*f4a2713aSLionel Sambuc   return (0);
388*f4a2713aSLionel Sambuc }
389*f4a2713aSLionel Sambuc int checkEqualBinaryOpFloatCompare4(void) {
390*f4a2713aSLionel Sambuc   int res;
391*f4a2713aSLionel Sambuc   float f= 3.14F;
392*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F == (char)f + 3.14F);  // no warning
393*f4a2713aSLionel Sambuc   return (0);
394*f4a2713aSLionel Sambuc }
395*f4a2713aSLionel Sambuc 
396*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpFloatCompare1(void) {
397*f4a2713aSLionel Sambuc   int res;
398*f4a2713aSLionel Sambuc   int t= 1;
399*f4a2713aSLionel Sambuc   int u= 2;
400*f4a2713aSLionel Sambuc   float f= 3.14F;
401*f4a2713aSLionel Sambuc   res = (((int)f + (3.14F - u)*t) == ((int)f + (3.14F - u)*t));  // no warning
402*f4a2713aSLionel Sambuc   return (0);
403*f4a2713aSLionel Sambuc }
404*f4a2713aSLionel Sambuc 
405*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpFloatCompare2(void) {
406*f4a2713aSLionel Sambuc   int res;
407*f4a2713aSLionel Sambuc   int t= 1;
408*f4a2713aSLionel Sambuc   int u= 2;
409*f4a2713aSLionel Sambuc   float f= 3.14F;
410*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) == ((int)f + (3.14F - u)*t));  // no warning
411*f4a2713aSLionel Sambuc   return (0);
412*f4a2713aSLionel Sambuc }
413*f4a2713aSLionel Sambuc 
414*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpFloatCompare3(void) {
415*f4a2713aSLionel Sambuc   int res;
416*f4a2713aSLionel Sambuc   int t= 1;
417*f4a2713aSLionel Sambuc   int u= 2;
418*f4a2713aSLionel Sambuc   float f= 3.14F;
419*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) == ((int)f + (3.14F - u)*(f + t == f + t)));  // no warning
420*f4a2713aSLionel Sambuc   return (0);
421*f4a2713aSLionel Sambuc }
422*f4a2713aSLionel Sambuc 
423*f4a2713aSLionel Sambuc 
424*f4a2713aSLionel Sambuc 
425*f4a2713aSLionel Sambuc 
426*f4a2713aSLionel Sambuc 
427*f4a2713aSLionel Sambuc /* Equal with int*/
428*f4a2713aSLionel Sambuc 
429*f4a2713aSLionel Sambuc int checkEqualIntLiteralCompare1(void) {
430*f4a2713aSLionel Sambuc   return (5 == 5); // expected-warning {{comparison of identical expressions always evaluates to true}}
431*f4a2713aSLionel Sambuc }
432*f4a2713aSLionel Sambuc 
433*f4a2713aSLionel Sambuc int checkEqualIntLiteralCompare2(void) {
434*f4a2713aSLionel Sambuc   return (6 == 7); // no warning
435*f4a2713aSLionel Sambuc }
436*f4a2713aSLionel Sambuc 
437*f4a2713aSLionel Sambuc int checkEqualIntDeclCompare1(void) {
438*f4a2713aSLionel Sambuc   int f = 7;
439*f4a2713aSLionel Sambuc   int g = 7;
440*f4a2713aSLionel Sambuc   return (f == g); // no warning
441*f4a2713aSLionel Sambuc }
442*f4a2713aSLionel Sambuc 
443*f4a2713aSLionel Sambuc int checkEqualCastIntDeclCompare11(void) {
444*f4a2713aSLionel Sambuc   int f = 7;
445*f4a2713aSLionel Sambuc   return ((int)f == (int)f); // expected-warning {{comparison of identical expressions always evaluates to true}}
446*f4a2713aSLionel Sambuc }
447*f4a2713aSLionel Sambuc int checkEqualCastIntDeclCompare12(void) {
448*f4a2713aSLionel Sambuc   int f = 7;
449*f4a2713aSLionel Sambuc   return ((char)f == (int)f); // no warning
450*f4a2713aSLionel Sambuc }
451*f4a2713aSLionel Sambuc 
452*f4a2713aSLionel Sambuc int checkEqualIntDeclCompare3(void) {
453*f4a2713aSLionel Sambuc   int f = 7;
454*f4a2713aSLionel Sambuc   return (f == 7); // no warning
455*f4a2713aSLionel Sambuc }
456*f4a2713aSLionel Sambuc 
457*f4a2713aSLionel Sambuc int checkEqualIntDeclCompare4(void) {
458*f4a2713aSLionel Sambuc   int f = 7;
459*f4a2713aSLionel Sambuc   return (7 == f); // no warning
460*f4a2713aSLionel Sambuc }
461*f4a2713aSLionel Sambuc 
462*f4a2713aSLionel Sambuc int checkEqualBinaryOpIntCompare1(void) {
463*f4a2713aSLionel Sambuc   int res;
464*f4a2713aSLionel Sambuc   int t= 1;
465*f4a2713aSLionel Sambuc   int u= 2;
466*f4a2713aSLionel Sambuc   int f= 4;
467*f4a2713aSLionel Sambuc   res = (f + 4 == f + 4);  // expected-warning {{comparison of identical expressions always evaluates to true}}
468*f4a2713aSLionel Sambuc   return (0);
469*f4a2713aSLionel Sambuc }
470*f4a2713aSLionel Sambuc int checkEqualBinaryOpIntCompare2(void) {
471*f4a2713aSLionel Sambuc   int f = 7;
472*f4a2713aSLionel Sambuc   int g = 7;
473*f4a2713aSLionel Sambuc   return (f + 4 == g + 4); // no warning
474*f4a2713aSLionel Sambuc }
475*f4a2713aSLionel Sambuc 
476*f4a2713aSLionel Sambuc 
477*f4a2713aSLionel Sambuc int checkEqualBinaryOpIntCompare3(void) {
478*f4a2713aSLionel Sambuc   int res;
479*f4a2713aSLionel Sambuc   int t= 1;
480*f4a2713aSLionel Sambuc   int u= 2;
481*f4a2713aSLionel Sambuc   int f= 4;
482*f4a2713aSLionel Sambuc   res = ((int)f + 4 == (int)f + 4);  // expected-warning {{comparison of identical expressions always evaluates to true}}
483*f4a2713aSLionel Sambuc   return (0);
484*f4a2713aSLionel Sambuc 
485*f4a2713aSLionel Sambuc }
486*f4a2713aSLionel Sambuc int checkEqualBinaryOpIntCompare4(void) {
487*f4a2713aSLionel Sambuc   int res;
488*f4a2713aSLionel Sambuc   int t= 1;
489*f4a2713aSLionel Sambuc   int u= 2;
490*f4a2713aSLionel Sambuc   int f= 4;
491*f4a2713aSLionel Sambuc   res = ((int)f + 4 == (char)f + 4);  // no warning
492*f4a2713aSLionel Sambuc   return (0);
493*f4a2713aSLionel Sambuc }
494*f4a2713aSLionel Sambuc int checkEqualBinaryOpIntCompare5(void) {
495*f4a2713aSLionel Sambuc   int res;
496*f4a2713aSLionel Sambuc   int t= 1;
497*f4a2713aSLionel Sambuc   int u= 2;
498*f4a2713aSLionel Sambuc   res = (u + t == u + t);  // expected-warning {{comparison of identical expressions always evaluates to true}}
499*f4a2713aSLionel Sambuc   return (0);
500*f4a2713aSLionel Sambuc }
501*f4a2713aSLionel Sambuc 
502*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpIntCompare1(void) {
503*f4a2713aSLionel Sambuc   int res;
504*f4a2713aSLionel Sambuc   int t= 1;
505*f4a2713aSLionel Sambuc   int u= 2;
506*f4a2713aSLionel Sambuc   int f= 3;
507*f4a2713aSLionel Sambuc   res = (((int)f + (3 - u)*t) == ((int)f + (3 - u)*t));  // expected-warning {{comparison of identical expressions always evaluates to true}}
508*f4a2713aSLionel Sambuc   return (0);
509*f4a2713aSLionel Sambuc }
510*f4a2713aSLionel Sambuc 
511*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpIntCompare2(void) {
512*f4a2713aSLionel Sambuc   int res;
513*f4a2713aSLionel Sambuc   int t= 1;
514*f4a2713aSLionel Sambuc   int u= 2;
515*f4a2713aSLionel Sambuc   int f= 3;
516*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) == ((int)f + (3 - u)*t));  // no warning
517*f4a2713aSLionel Sambuc   return (0);
518*f4a2713aSLionel Sambuc }
519*f4a2713aSLionel Sambuc 
520*f4a2713aSLionel Sambuc int checkEqualNestedBinaryOpIntCompare3(void) {
521*f4a2713aSLionel Sambuc   int res;
522*f4a2713aSLionel Sambuc   int t= 1;
523*f4a2713aSLionel Sambuc   int u= 2;
524*f4a2713aSLionel Sambuc   int f= 3;
525*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) == ((int)f + (3 - u)*(t + 1 == t + 1)));  // expected-warning {{comparison of identical expressions always evaluates to true}}
526*f4a2713aSLionel Sambuc   return (0);
527*f4a2713aSLionel Sambuc }
528*f4a2713aSLionel Sambuc 
529*f4a2713aSLionel Sambuc 
530*f4a2713aSLionel Sambuc /*   end EQ int          */
531*f4a2713aSLionel Sambuc 
532*f4a2713aSLionel Sambuc /* end EQ */
533*f4a2713aSLionel Sambuc 
534*f4a2713aSLionel Sambuc 
535*f4a2713aSLionel Sambuc /*  LT */
536*f4a2713aSLionel Sambuc 
537*f4a2713aSLionel Sambuc /*  LT with float */
538*f4a2713aSLionel Sambuc 
539*f4a2713aSLionel Sambuc int checkLessThanFloatLiteralCompare1(void) {
540*f4a2713aSLionel Sambuc   return (5.14F < 5.14F); // expected-warning {{comparison of identical expressions always evaluates to false}}
541*f4a2713aSLionel Sambuc }
542*f4a2713aSLionel Sambuc 
543*f4a2713aSLionel Sambuc int checkLessThanFloatLiteralCompare2(void) {
544*f4a2713aSLionel Sambuc   return (6.14F < 7.14F); // no warning
545*f4a2713aSLionel Sambuc }
546*f4a2713aSLionel Sambuc 
547*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare1(void) {
548*f4a2713aSLionel Sambuc   float f = 7.1F;
549*f4a2713aSLionel Sambuc   float g = 7.1F;
550*f4a2713aSLionel Sambuc   return (f < g); // no warning
551*f4a2713aSLionel Sambuc }
552*f4a2713aSLionel Sambuc 
553*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare12(void) {
554*f4a2713aSLionel Sambuc   float f = 7.1F;
555*f4a2713aSLionel Sambuc   return (f < f); // expected-warning {{comparison of identical expressions always evaluates to false}}
556*f4a2713aSLionel Sambuc }
557*f4a2713aSLionel Sambuc 
558*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare3(void) {
559*f4a2713aSLionel Sambuc   float f = 7.1F;
560*f4a2713aSLionel Sambuc   return (f < 7.1F); // no warning
561*f4a2713aSLionel Sambuc }
562*f4a2713aSLionel Sambuc 
563*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare4(void) {
564*f4a2713aSLionel Sambuc   float f = 7.1F;
565*f4a2713aSLionel Sambuc   return (7.1F < f); // no warning
566*f4a2713aSLionel Sambuc }
567*f4a2713aSLionel Sambuc 
568*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare5(void) {
569*f4a2713aSLionel Sambuc   float f = 7.1F;
570*f4a2713aSLionel Sambuc   int t = 7;
571*f4a2713aSLionel Sambuc   return (t < f); // no warning
572*f4a2713aSLionel Sambuc }
573*f4a2713aSLionel Sambuc 
574*f4a2713aSLionel Sambuc int checkLessThanFloatDeclCompare6(void) {
575*f4a2713aSLionel Sambuc   float f = 7.1F;
576*f4a2713aSLionel Sambuc   int t = 7;
577*f4a2713aSLionel Sambuc   return (f < t); // no warning
578*f4a2713aSLionel Sambuc }
579*f4a2713aSLionel Sambuc 
580*f4a2713aSLionel Sambuc 
581*f4a2713aSLionel Sambuc int checkLessThanCastFloatDeclCompare11(void) {
582*f4a2713aSLionel Sambuc   float f = 7.1F;
583*f4a2713aSLionel Sambuc   return ((int)f < (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
584*f4a2713aSLionel Sambuc }
585*f4a2713aSLionel Sambuc int checkLessThanCastFloatDeclCompare12(void) {
586*f4a2713aSLionel Sambuc   float f = 7.1F;
587*f4a2713aSLionel Sambuc   return ((char)f < (int)f); // no warning
588*f4a2713aSLionel Sambuc }
589*f4a2713aSLionel Sambuc int checkLessThanBinaryOpFloatCompare1(void) {
590*f4a2713aSLionel Sambuc   int res;
591*f4a2713aSLionel Sambuc   float f= 3.14F;
592*f4a2713aSLionel Sambuc   res = (f + 3.14F < f + 3.14F);  // no warning
593*f4a2713aSLionel Sambuc   return (0);
594*f4a2713aSLionel Sambuc }
595*f4a2713aSLionel Sambuc int checkLessThanBinaryOpFloatCompare2(void) {
596*f4a2713aSLionel Sambuc   float f = 7.1F;
597*f4a2713aSLionel Sambuc   float g = 7.1F;
598*f4a2713aSLionel Sambuc   return (f + 3.14F < g + 3.14F); // no warning
599*f4a2713aSLionel Sambuc }
600*f4a2713aSLionel Sambuc int checkLessThanBinaryOpFloatCompare3(void) {
601*f4a2713aSLionel Sambuc   int res;
602*f4a2713aSLionel Sambuc   float f= 3.14F;
603*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F < (int)f + 3.14F);  // no warning
604*f4a2713aSLionel Sambuc   return (0);
605*f4a2713aSLionel Sambuc }
606*f4a2713aSLionel Sambuc int checkLessThanBinaryOpFloatCompare4(void) {
607*f4a2713aSLionel Sambuc   int res;
608*f4a2713aSLionel Sambuc   float f= 3.14F;
609*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F < (char)f + 3.14F);  // no warning
610*f4a2713aSLionel Sambuc   return (0);
611*f4a2713aSLionel Sambuc }
612*f4a2713aSLionel Sambuc 
613*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpFloatCompare1(void) {
614*f4a2713aSLionel Sambuc   int res;
615*f4a2713aSLionel Sambuc   int t= 1;
616*f4a2713aSLionel Sambuc   int u= 2;
617*f4a2713aSLionel Sambuc   float f= 3.14F;
618*f4a2713aSLionel Sambuc   res = (((int)f + (3.14F - u)*t) < ((int)f + (3.14F - u)*t));  // no warning
619*f4a2713aSLionel Sambuc   return (0);
620*f4a2713aSLionel Sambuc }
621*f4a2713aSLionel Sambuc 
622*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpFloatCompare2(void) {
623*f4a2713aSLionel Sambuc   int res;
624*f4a2713aSLionel Sambuc   int t= 1;
625*f4a2713aSLionel Sambuc   int u= 2;
626*f4a2713aSLionel Sambuc   float f= 3.14F;
627*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) < ((int)f + (3.14F - u)*t));  // no warning
628*f4a2713aSLionel Sambuc   return (0);
629*f4a2713aSLionel Sambuc }
630*f4a2713aSLionel Sambuc 
631*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpFloatCompare3(void) {
632*f4a2713aSLionel Sambuc   int res;
633*f4a2713aSLionel Sambuc   int t= 1;
634*f4a2713aSLionel Sambuc   int u= 2;
635*f4a2713aSLionel Sambuc   float f= 3.14F;
636*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) < ((int)f + (3.14F - u)*(f + t < f + t)));  // no warning
637*f4a2713aSLionel Sambuc   return (0);
638*f4a2713aSLionel Sambuc }
639*f4a2713aSLionel Sambuc 
640*f4a2713aSLionel Sambuc /*  end LT with float */
641*f4a2713aSLionel Sambuc 
642*f4a2713aSLionel Sambuc /*  LT with int */
643*f4a2713aSLionel Sambuc 
644*f4a2713aSLionel Sambuc 
645*f4a2713aSLionel Sambuc int checkLessThanIntLiteralCompare1(void) {
646*f4a2713aSLionel Sambuc   return (5 < 5); // expected-warning {{comparison of identical expressions always evaluates to false}}
647*f4a2713aSLionel Sambuc }
648*f4a2713aSLionel Sambuc 
649*f4a2713aSLionel Sambuc int checkLessThanIntLiteralCompare2(void) {
650*f4a2713aSLionel Sambuc   return (6 < 7); // no warning
651*f4a2713aSLionel Sambuc }
652*f4a2713aSLionel Sambuc 
653*f4a2713aSLionel Sambuc int checkLessThanIntDeclCompare1(void) {
654*f4a2713aSLionel Sambuc   int f = 7;
655*f4a2713aSLionel Sambuc   int g = 7;
656*f4a2713aSLionel Sambuc   return (f < g); // no warning
657*f4a2713aSLionel Sambuc }
658*f4a2713aSLionel Sambuc 
659*f4a2713aSLionel Sambuc int checkLessThanIntDeclCompare3(void) {
660*f4a2713aSLionel Sambuc   int f = 7;
661*f4a2713aSLionel Sambuc   return (f < 7); // no warning
662*f4a2713aSLionel Sambuc }
663*f4a2713aSLionel Sambuc 
664*f4a2713aSLionel Sambuc int checkLessThanIntDeclCompare4(void) {
665*f4a2713aSLionel Sambuc   int f = 7;
666*f4a2713aSLionel Sambuc   return (7 < f); // no warning
667*f4a2713aSLionel Sambuc }
668*f4a2713aSLionel Sambuc 
669*f4a2713aSLionel Sambuc int checkLessThanIntDeclCompare5(void) {
670*f4a2713aSLionel Sambuc   int f = 7;
671*f4a2713aSLionel Sambuc   int t = 7;
672*f4a2713aSLionel Sambuc   return (t < f); // no warning
673*f4a2713aSLionel Sambuc }
674*f4a2713aSLionel Sambuc 
675*f4a2713aSLionel Sambuc int checkLessThanIntDeclCompare6(void) {
676*f4a2713aSLionel Sambuc   int f = 7;
677*f4a2713aSLionel Sambuc   int t = 7;
678*f4a2713aSLionel Sambuc   return (f < t); // no warning
679*f4a2713aSLionel Sambuc }
680*f4a2713aSLionel Sambuc 
681*f4a2713aSLionel Sambuc int checkLessThanCastIntDeclCompare11(void) {
682*f4a2713aSLionel Sambuc   int f = 7;
683*f4a2713aSLionel Sambuc   return ((int)f < (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
684*f4a2713aSLionel Sambuc }
685*f4a2713aSLionel Sambuc int checkLessThanCastIntDeclCompare12(void) {
686*f4a2713aSLionel Sambuc   int f = 7;
687*f4a2713aSLionel Sambuc   return ((char)f < (int)f); // no warning
688*f4a2713aSLionel Sambuc }
689*f4a2713aSLionel Sambuc int checkLessThanBinaryOpIntCompare1(void) {
690*f4a2713aSLionel Sambuc   int res;
691*f4a2713aSLionel Sambuc   int f= 3;
692*f4a2713aSLionel Sambuc   res = (f + 3 < f + 3);  // expected-warning {{comparison of identical expressions always evaluates to false}}
693*f4a2713aSLionel Sambuc   return (0);
694*f4a2713aSLionel Sambuc }
695*f4a2713aSLionel Sambuc int checkLessThanBinaryOpIntCompare2(void) {
696*f4a2713aSLionel Sambuc   int f = 7;
697*f4a2713aSLionel Sambuc   int g = 7;
698*f4a2713aSLionel Sambuc   return (f + 3 < g + 3); // no warning
699*f4a2713aSLionel Sambuc }
700*f4a2713aSLionel Sambuc int checkLessThanBinaryOpIntCompare3(void) {
701*f4a2713aSLionel Sambuc   int res;
702*f4a2713aSLionel Sambuc   int f= 3;
703*f4a2713aSLionel Sambuc   res = ((int)f + 3 < (int)f + 3);  // expected-warning {{comparison of identical expressions always evaluates to false}}
704*f4a2713aSLionel Sambuc   return (0);
705*f4a2713aSLionel Sambuc }
706*f4a2713aSLionel Sambuc int checkLessThanBinaryOpIntCompare4(void) {
707*f4a2713aSLionel Sambuc   int res;
708*f4a2713aSLionel Sambuc   int f= 3;
709*f4a2713aSLionel Sambuc   res = ((int)f + 3 < (char)f + 3);  // no warning
710*f4a2713aSLionel Sambuc   return (0);
711*f4a2713aSLionel Sambuc }
712*f4a2713aSLionel Sambuc 
713*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpIntCompare1(void) {
714*f4a2713aSLionel Sambuc   int res;
715*f4a2713aSLionel Sambuc   int t= 1;
716*f4a2713aSLionel Sambuc   int u= 2;
717*f4a2713aSLionel Sambuc   int f= 3;
718*f4a2713aSLionel Sambuc   res = (((int)f + (3 - u)*t) < ((int)f + (3 - u)*t));  // expected-warning {{comparison of identical expressions always evaluates to false}}
719*f4a2713aSLionel Sambuc   return (0);
720*f4a2713aSLionel Sambuc }
721*f4a2713aSLionel Sambuc 
722*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpIntCompare2(void) {
723*f4a2713aSLionel Sambuc   int res;
724*f4a2713aSLionel Sambuc   int t= 1;
725*f4a2713aSLionel Sambuc   int u= 2;
726*f4a2713aSLionel Sambuc   int f= 3;
727*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) < ((int)f + (3 - u)*t));  // no warning
728*f4a2713aSLionel Sambuc   return (0);
729*f4a2713aSLionel Sambuc }
730*f4a2713aSLionel Sambuc 
731*f4a2713aSLionel Sambuc int checkLessThanNestedBinaryOpIntCompare3(void) {
732*f4a2713aSLionel Sambuc   int res;
733*f4a2713aSLionel Sambuc   int t= 1;
734*f4a2713aSLionel Sambuc   int u= 2;
735*f4a2713aSLionel Sambuc   int f= 3;
736*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) < ((int)f + (3 - u)*(t + u < t + u)));  // expected-warning {{comparison of identical expressions always evaluates to false}}
737*f4a2713aSLionel Sambuc   return (0);
738*f4a2713aSLionel Sambuc }
739*f4a2713aSLionel Sambuc 
740*f4a2713aSLionel Sambuc /* end LT with int */
741*f4a2713aSLionel Sambuc 
742*f4a2713aSLionel Sambuc /* end LT */
743*f4a2713aSLionel Sambuc 
744*f4a2713aSLionel Sambuc 
745*f4a2713aSLionel Sambuc /* GT */
746*f4a2713aSLionel Sambuc 
747*f4a2713aSLionel Sambuc /* GT with float */
748*f4a2713aSLionel Sambuc 
749*f4a2713aSLionel Sambuc int checkGreaterThanFloatLiteralCompare1(void) {
750*f4a2713aSLionel Sambuc   return (5.14F > 5.14F); // expected-warning {{comparison of identical expressions always evaluates to false}}
751*f4a2713aSLionel Sambuc }
752*f4a2713aSLionel Sambuc 
753*f4a2713aSLionel Sambuc int checkGreaterThanFloatLiteralCompare2(void) {
754*f4a2713aSLionel Sambuc   return (6.14F > 7.14F); // no warning
755*f4a2713aSLionel Sambuc }
756*f4a2713aSLionel Sambuc 
757*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare1(void) {
758*f4a2713aSLionel Sambuc   float f = 7.1F;
759*f4a2713aSLionel Sambuc   float g = 7.1F;
760*f4a2713aSLionel Sambuc 
761*f4a2713aSLionel Sambuc   return (f > g); // no warning
762*f4a2713aSLionel Sambuc }
763*f4a2713aSLionel Sambuc 
764*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare12(void) {
765*f4a2713aSLionel Sambuc   float f = 7.1F;
766*f4a2713aSLionel Sambuc   return (f > f); // expected-warning {{comparison of identical expressions always evaluates to false}}
767*f4a2713aSLionel Sambuc }
768*f4a2713aSLionel Sambuc 
769*f4a2713aSLionel Sambuc 
770*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare3(void) {
771*f4a2713aSLionel Sambuc   float f = 7.1F;
772*f4a2713aSLionel Sambuc   return (f > 7.1F); // no warning
773*f4a2713aSLionel Sambuc }
774*f4a2713aSLionel Sambuc 
775*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare4(void) {
776*f4a2713aSLionel Sambuc   float f = 7.1F;
777*f4a2713aSLionel Sambuc   return (7.1F > f); // no warning
778*f4a2713aSLionel Sambuc }
779*f4a2713aSLionel Sambuc 
780*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare5(void) {
781*f4a2713aSLionel Sambuc   float f = 7.1F;
782*f4a2713aSLionel Sambuc   int t = 7;
783*f4a2713aSLionel Sambuc   return (t > f); // no warning
784*f4a2713aSLionel Sambuc }
785*f4a2713aSLionel Sambuc 
786*f4a2713aSLionel Sambuc int checkGreaterThanFloatDeclCompare6(void) {
787*f4a2713aSLionel Sambuc   float f = 7.1F;
788*f4a2713aSLionel Sambuc   int t = 7;
789*f4a2713aSLionel Sambuc   return (f > t); // no warning
790*f4a2713aSLionel Sambuc }
791*f4a2713aSLionel Sambuc 
792*f4a2713aSLionel Sambuc int checkGreaterThanCastFloatDeclCompare11(void) {
793*f4a2713aSLionel Sambuc   float f = 7.1F;
794*f4a2713aSLionel Sambuc   return ((int)f > (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
795*f4a2713aSLionel Sambuc }
796*f4a2713aSLionel Sambuc int checkGreaterThanCastFloatDeclCompare12(void) {
797*f4a2713aSLionel Sambuc   float f = 7.1F;
798*f4a2713aSLionel Sambuc   return ((char)f > (int)f); // no warning
799*f4a2713aSLionel Sambuc }
800*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpFloatCompare1(void) {
801*f4a2713aSLionel Sambuc   int res;
802*f4a2713aSLionel Sambuc   float f= 3.14F;
803*f4a2713aSLionel Sambuc   res = (f + 3.14F > f + 3.14F);  // no warning
804*f4a2713aSLionel Sambuc   return (0);
805*f4a2713aSLionel Sambuc }
806*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpFloatCompare2(void) {
807*f4a2713aSLionel Sambuc   float f = 7.1F;
808*f4a2713aSLionel Sambuc   float g = 7.1F;
809*f4a2713aSLionel Sambuc   return (f + 3.14F > g + 3.14F); // no warning
810*f4a2713aSLionel Sambuc }
811*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpFloatCompare3(void) {
812*f4a2713aSLionel Sambuc   int res;
813*f4a2713aSLionel Sambuc   float f= 3.14F;
814*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F > (int)f + 3.14F);  // no warning
815*f4a2713aSLionel Sambuc   return (0);
816*f4a2713aSLionel Sambuc }
817*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpFloatCompare4(void) {
818*f4a2713aSLionel Sambuc   int res;
819*f4a2713aSLionel Sambuc   float f= 3.14F;
820*f4a2713aSLionel Sambuc   res = ((int)f + 3.14F > (char)f + 3.14F);  // no warning
821*f4a2713aSLionel Sambuc   return (0);
822*f4a2713aSLionel Sambuc }
823*f4a2713aSLionel Sambuc 
824*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpFloatCompare1(void) {
825*f4a2713aSLionel Sambuc   int res;
826*f4a2713aSLionel Sambuc   int t= 1;
827*f4a2713aSLionel Sambuc   int u= 2;
828*f4a2713aSLionel Sambuc   float f= 3.14F;
829*f4a2713aSLionel Sambuc   res = (((int)f + (3.14F - u)*t) > ((int)f + (3.14F - u)*t));  // no warning
830*f4a2713aSLionel Sambuc   return (0);
831*f4a2713aSLionel Sambuc }
832*f4a2713aSLionel Sambuc 
833*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpFloatCompare2(void) {
834*f4a2713aSLionel Sambuc   int res;
835*f4a2713aSLionel Sambuc   int t= 1;
836*f4a2713aSLionel Sambuc   int u= 2;
837*f4a2713aSLionel Sambuc   float f= 3.14F;
838*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) > ((int)f + (3.14F - u)*t));  // no warning
839*f4a2713aSLionel Sambuc   return (0);
840*f4a2713aSLionel Sambuc }
841*f4a2713aSLionel Sambuc 
842*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpFloatCompare3(void) {
843*f4a2713aSLionel Sambuc   int res;
844*f4a2713aSLionel Sambuc   int t= 1;
845*f4a2713aSLionel Sambuc   int u= 2;
846*f4a2713aSLionel Sambuc   float f= 3.14F;
847*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3.14F)*t) > ((int)f + (3.14F - u)*(f + t > f + t)));  // no warning
848*f4a2713aSLionel Sambuc   return (0);
849*f4a2713aSLionel Sambuc }
850*f4a2713aSLionel Sambuc 
851*f4a2713aSLionel Sambuc /*  end GT with float */
852*f4a2713aSLionel Sambuc 
853*f4a2713aSLionel Sambuc /*  GT with int */
854*f4a2713aSLionel Sambuc 
855*f4a2713aSLionel Sambuc 
856*f4a2713aSLionel Sambuc int checkGreaterThanIntLiteralCompare1(void) {
857*f4a2713aSLionel Sambuc   return (5 > 5); // expected-warning {{comparison of identical expressions always evaluates to false}}
858*f4a2713aSLionel Sambuc }
859*f4a2713aSLionel Sambuc 
860*f4a2713aSLionel Sambuc int checkGreaterThanIntLiteralCompare2(void) {
861*f4a2713aSLionel Sambuc   return (6 > 7); // no warning
862*f4a2713aSLionel Sambuc }
863*f4a2713aSLionel Sambuc 
864*f4a2713aSLionel Sambuc int checkGreaterThanIntDeclCompare1(void) {
865*f4a2713aSLionel Sambuc   int f = 7;
866*f4a2713aSLionel Sambuc   int g = 7;
867*f4a2713aSLionel Sambuc 
868*f4a2713aSLionel Sambuc   return (f > g); // no warning
869*f4a2713aSLionel Sambuc }
870*f4a2713aSLionel Sambuc 
871*f4a2713aSLionel Sambuc int checkGreaterThanIntDeclCompare3(void) {
872*f4a2713aSLionel Sambuc   int f = 7;
873*f4a2713aSLionel Sambuc   return (f > 7); // no warning
874*f4a2713aSLionel Sambuc }
875*f4a2713aSLionel Sambuc 
876*f4a2713aSLionel Sambuc int checkGreaterThanIntDeclCompare4(void) {
877*f4a2713aSLionel Sambuc   int f = 7;
878*f4a2713aSLionel Sambuc   return (7 > f); // no warning
879*f4a2713aSLionel Sambuc }
880*f4a2713aSLionel Sambuc 
881*f4a2713aSLionel Sambuc int checkGreaterThanCastIntDeclCompare11(void) {
882*f4a2713aSLionel Sambuc   int f = 7;
883*f4a2713aSLionel Sambuc   return ((int)f > (int)f); // expected-warning {{comparison of identical expressions always evaluates to false}}
884*f4a2713aSLionel Sambuc }
885*f4a2713aSLionel Sambuc int checkGreaterThanCastIntDeclCompare12(void) {
886*f4a2713aSLionel Sambuc   int f = 7;
887*f4a2713aSLionel Sambuc   return ((char)f > (int)f); // no warning
888*f4a2713aSLionel Sambuc }
889*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpIntCompare1(void) {
890*f4a2713aSLionel Sambuc   int res;
891*f4a2713aSLionel Sambuc   int f= 3;
892*f4a2713aSLionel Sambuc   res = (f + 3 > f + 3);  // expected-warning {{comparison of identical expressions always evaluates to false}}
893*f4a2713aSLionel Sambuc   return (0);
894*f4a2713aSLionel Sambuc }
895*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpIntCompare2(void) {
896*f4a2713aSLionel Sambuc   int f = 7;
897*f4a2713aSLionel Sambuc   int g = 7;
898*f4a2713aSLionel Sambuc   return (f + 3 > g + 3); // no warning
899*f4a2713aSLionel Sambuc }
900*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpIntCompare3(void) {
901*f4a2713aSLionel Sambuc   int res;
902*f4a2713aSLionel Sambuc   int f= 3;
903*f4a2713aSLionel Sambuc   res = ((int)f + 3 > (int)f + 3);  // expected-warning {{comparison of identical expressions always evaluates to false}}
904*f4a2713aSLionel Sambuc   return (0);
905*f4a2713aSLionel Sambuc }
906*f4a2713aSLionel Sambuc int checkGreaterThanBinaryOpIntCompare4(void) {
907*f4a2713aSLionel Sambuc   int res;
908*f4a2713aSLionel Sambuc   int f= 3;
909*f4a2713aSLionel Sambuc   res = ((int)f + 3 > (char)f + 3);  // no warning
910*f4a2713aSLionel Sambuc   return (0);
911*f4a2713aSLionel Sambuc }
912*f4a2713aSLionel Sambuc 
913*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpIntCompare1(void) {
914*f4a2713aSLionel Sambuc   int res;
915*f4a2713aSLionel Sambuc   int t= 1;
916*f4a2713aSLionel Sambuc   int u= 2;
917*f4a2713aSLionel Sambuc   int f= 3;
918*f4a2713aSLionel Sambuc   res = (((int)f + (3 - u)*t) > ((int)f + (3 - u)*t));  // expected-warning {{comparison of identical expressions always evaluates to false}}
919*f4a2713aSLionel Sambuc   return (0);
920*f4a2713aSLionel Sambuc }
921*f4a2713aSLionel Sambuc 
922*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpIntCompare2(void) {
923*f4a2713aSLionel Sambuc   int res;
924*f4a2713aSLionel Sambuc   int t= 1;
925*f4a2713aSLionel Sambuc   int u= 2;
926*f4a2713aSLionel Sambuc   int f= 3;
927*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) > ((int)f + (3 - u)*t));  // no warning
928*f4a2713aSLionel Sambuc   return (0);
929*f4a2713aSLionel Sambuc }
930*f4a2713aSLionel Sambuc 
931*f4a2713aSLionel Sambuc int checkGreaterThanNestedBinaryOpIntCompare3(void) {
932*f4a2713aSLionel Sambuc   int res;
933*f4a2713aSLionel Sambuc   int t= 1;
934*f4a2713aSLionel Sambuc   int u= 2;
935*f4a2713aSLionel Sambuc   int f= 3;
936*f4a2713aSLionel Sambuc   res = (((int)f + (u - 3)*t) > ((int)f + (3 - u)*(t + u > t + u)));  // expected-warning {{comparison of identical expressions always evaluates to false}}
937*f4a2713aSLionel Sambuc   return (0);
938*f4a2713aSLionel Sambuc }
939*f4a2713aSLionel Sambuc 
940*f4a2713aSLionel Sambuc /* end GT with int */
941*f4a2713aSLionel Sambuc 
942*f4a2713aSLionel Sambuc /* end GT */
943