diff options
Diffstat (limited to 'test/Sema/compare.c')
| -rw-r--r-- | test/Sema/compare.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 87131bb62183..9cbbfba935bd 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -7,6 +7,26 @@ 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}} + + enum Enum {B}; + return (a == B) + + ((int)a == B) + + ((short)a == B) + + (a == (unsigned int) B) + // expected-warning {{comparison of integers of different signs}} + (a == (unsigned short) B); // expected-warning {{comparison of integers of different signs}} + + // Should be able to prove all of these are non-negative. + return (b == (long) B) + + (b == (int) B) + + (b == (short) B); +} + int equal(char *a, const char *b) { return a == b; } |
