diff options
author | John McCall <rjmccall@apple.com> | 2010-03-11 19:43:18 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-11 19:43:18 +0000 |
commit | d1b47bf17fde73fac67d8664bd65273742c00ecd (patch) | |
tree | 0cea232c72cbc5a9ebd3ad9079fe5e18e3e1dbec /test/Sema/compare.c | |
parent | d7358a3a63e66aafc49f394613a3afe4403d7c6b (diff) |
Warn about comparing an unsigned expression with 0 in tautological ways.
Patch by mikem!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/compare.c')
-rw-r--r-- | test/Sema/compare.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 2821a935c3..7c8c36f0c1 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -274,3 +274,11 @@ void test4() { if (value < (unsigned long) &ptr4) // expected-warning {{comparison of integers of different signs}} return; } + +// PR4807 +int test5(unsigned int x) { + return (x < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}} + && (0 > x) // expected-warning {{comparison of 0 > unsigned expression is always false}} + && (x >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}} + && (0 <= x); // expected-warning {{comparison of 0 <= unsigned expression is always true}} +} |