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 | 71d8d9b4688b09f78c50fc303100f45e389952b1 (patch) | |
| tree | 0efc22f14c1e66696e30a6df3a7b6394d82b21ec /clang/test | |
| parent | 2562356992ba1f57f2302f4fcf25ad84dad8990e (diff) | |
| download | bcm5719-llvm-71d8d9b4688b09f78c50fc303100f45e389952b1.tar.gz bcm5719-llvm-71d8d9b4688b09f78c50fc303100f45e389952b1.zip | |
Warn about comparing an unsigned expression with 0 in tautological ways.
Patch by mikem!
llvm-svn: 98279
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/compare.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/Sema/compare.c b/clang/test/Sema/compare.c index 2821a935c3c..7c8c36f0c14 100644 --- a/clang/test/Sema/compare.c +++ b/clang/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}} +} |

