1 // RUN: %clang_cc1 -fsyntax-only \
2 // RUN: -Wtautological-unsigned-zero-compare \
4 // RUN: %clang_cc1 -fsyntax-only \
5 // RUN: -verify=silence %s
6 // RUN: %clang_cc1 -fsyntax-only \
7 // RUN: -Wtautological-unsigned-zero-compare \
8 // RUN: -verify -x c++ %s
9 // RUN: %clang_cc1 -fsyntax-only \
10 // RUN: -verify=silence -x c++ %s
12 unsigned uvalue(void);
13 signed int svalue(void);
15 #define macro(val) val
20 // Make sure that we do warn for normal variables in template functions !
21 unsigned char c
= svalue();
22 if (c
< 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
37 TFunc
<unsigned char>();
38 TFunc
<unsigned short>();
43 unsigned un
= uvalue();
45 // silence-no-diagnostics
47 // Note: both sides are promoted to unsigned long prior to the comparison.
52 if (s
< 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
58 if (s
>= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
67 if (0UL <= s
) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
69 if (0UL > s
) // expected-warning {{comparison of 0 > unsigned expression is always false}}
78 if (un
< 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
84 if (un
>= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
93 if (0 <= un
) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
95 if (0 > un
) // expected-warning {{comparison of 0 > unsigned expression is always false}}
104 if (un
< 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
110 if (un
>= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
119 if (0UL <= un
) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
121 if (0UL > un
) // expected-warning {{comparison of 0 > unsigned expression is always false}}
127 signed int a
= svalue();
159 if (a
< 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
165 if (a
>= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
174 if (0UL <= a
) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
176 if (0UL > a
) // expected-warning {{comparison of 0 > unsigned expression is always false}}