Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -pedantic -verify %s |
Chris Lattner | d28f815 | 2007-08-26 01:10:14 +0000 | [diff] [blame] | 2 | |
| 3 | int test(char *C) { // nothing here should warn. |
| 4 | return C != ((void*)0); |
| 5 | return C != (void*)0; |
| 6 | return C != 0; |
| 7 | } |
| 8 | |
Steve Naroff | 77878cc | 2007-08-27 04:08:11 +0000 | [diff] [blame] | 9 | int equal(char *a, const char *b) |
| 10 | { |
| 11 | return a == b; |
| 12 | } |
Eli Friedman | 4e92acf | 2008-02-06 04:53:22 +0000 | [diff] [blame] | 13 | |
| 14 | int arrays(char (*a)[5], char(*b)[10], char(*c)[5]) { |
| 15 | int d = (a == c); |
| 16 | return a == b; // expected-warning {{comparison of distinct pointer types}} |
| 17 | } |
Chris Lattner | 149f138 | 2009-06-30 06:24:05 +0000 | [diff] [blame^] | 18 | |
| 19 | int pointers(int *a) |
| 20 | { |
| 21 | return a > 0; // expected-warning {{ordered comparison between pointer and integer}} |
| 22 | return a > (void *)0; // expected-warning {{comparison of distinct pointer types}} |
| 23 | } |
| 24 | |
| 25 | int function_pointers(int (*a)(int), int (*b)(int)) |
| 26 | { |
| 27 | return a > b; // expected-warning {{ordered comparison of function pointers}} |
| 28 | return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}} |
| 29 | return a == (void *) 0; |
| 30 | return a == (void *) 1; // expected-warning {{comparison of distinct pointer types}} |
| 31 | } |