2017-09-08 21:56:45 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
|
|
|
|
|
2017-10-13 06:03:20 +08:00
|
|
|
unsigned value(void);
|
2017-09-08 21:56:45 +08:00
|
|
|
|
2017-10-13 06:03:20 +08:00
|
|
|
int main() {
|
|
|
|
unsigned un = value();
|
2017-09-08 21:56:45 +08:00
|
|
|
|
|
|
|
#ifdef TEST
|
|
|
|
if (un < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (un >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (0 <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (0 > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
|
|
|
if (un < 0U) // expected-warning {{comparison of unsigned expression < 0 is always false}}
|
|
|
|
return 0;
|
|
|
|
if (un >= 0U) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
|
|
|
|
return 0;
|
|
|
|
if (0U <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
|
|
|
|
return 0;
|
|
|
|
if (0U > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
|
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
#else
|
|
|
|
// expected-no-diagnostics
|
|
|
|
if (un < 0)
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (un >= 0)
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (0 <= un)
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
if (0 > un)
|
2017-10-13 06:03:20 +08:00
|
|
|
return 0;
|
|
|
|
if (un < 0U)
|
|
|
|
return 0;
|
|
|
|
if (un >= 0U)
|
|
|
|
return 0;
|
|
|
|
if (0U <= un)
|
|
|
|
return 0;
|
|
|
|
if (0U > un)
|
|
|
|
return 0;
|
2017-09-08 21:56:45 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|