diff options
Diffstat (limited to 'test/Sema/compare.c')
-rw-r--r-- | test/Sema/compare.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 51f77317385c..87131bb62183 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -3,11 +3,11 @@ int test(char *C) { // nothing here should warn. return C != ((void*)0); return C != (void*)0; - return C != 0; + return C != 0; + return C != 1; // expected-warning {{comparison between pointer and integer ('char *' and 'int')}} } -int equal(char *a, const char *b) -{ +int equal(char *a, const char *b) { return a == b; } @@ -16,16 +16,21 @@ int arrays(char (*a)[5], char(*b)[10], char(*c)[5]) { return a == b; // expected-warning {{comparison of distinct pointer types}} } -int pointers(int *a) -{ - return a > 0; // expected-warning {{ordered comparison between pointer and integer}} +int pointers(int *a) { + return a > 0; // expected-warning {{ordered comparison between pointer and zero ('int *' and 'int') is an extension}} + return a > 42; // expected-warning {{ordered comparison between pointer and integer ('int *' and 'int')}} return a > (void *)0; // expected-warning {{comparison of distinct pointer types}} } -int function_pointers(int (*a)(int), int (*b)(int)) -{ +int function_pointers(int (*a)(int), int (*b)(int), void (*c)(int)) { return a > b; // expected-warning {{ordered comparison of function pointers}} return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}} + return a > c; // expected-warning {{comparison of distinct pointer types}} return a == (void *) 0; - return a == (void *) 1; // expected-warning {{comparison of distinct pointer types}} + return a == (void *) 1; // expected-warning {{equality comparison between function pointer and void pointer}} +} + +int void_pointers(void* foo) { + return foo == (void*) 0; + return foo == (void*) 1; } |