diff options
| author | John McCall <rjmccall@apple.com> | 2009-11-05 00:40:04 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2009-11-05 00:40:04 +0000 |
| commit | 644a4181c947bfc0dc7775fc4843c7c1e599ed7c (patch) | |
| tree | 8de23ba332040b74f34b82e80191313efd91d726 /clang/test/Sema/compare.c | |
| parent | 90d0b82e12c23ebd429d1f53ac9d013857cf3d47 (diff) | |
| download | bcm5719-llvm-644a4181c947bfc0dc7775fc4843c7c1e599ed7c.tar.gz bcm5719-llvm-644a4181c947bfc0dc7775fc4843c7c1e599ed7c.zip | |
Implement -Wsign-compare, or at least the actual comparison part of it.
Conditional operands are next.
Fixes part of rdar://problem/7289584.
llvm-svn: 86083
Diffstat (limited to 'clang/test/Sema/compare.c')
| -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 87131bb6218..50b40e459c3 100644 --- a/clang/test/Sema/compare.c +++ b/clang/test/Sema/compare.c @@ -7,6 +7,14 @@ int test(char *C) { // nothing here should warn. return C != 1; // expected-warning {{comparison between pointer and integer ('char *' and 'int')}} } +int ints(long a, unsigned long b) { + return (a == b) + // expected-warning {{comparison of integers of different signs}} + ((int)a == b) + // expected-warning {{comparison of integers of different signs}} + ((short)a == b) + // expected-warning {{comparison of integers of different signs}} + (a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}} + (a == (unsigned short) b); // expected-warning {{comparison of integers of different signs}} +} + int equal(char *a, const char *b) { return a == b; } |

