| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s -std=c11 |
| 2 |
|
| 3 |
int test1(int *a) { |
| 4 |
return a == '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 5 |
} |
| 6 |
|
| 7 |
int test2(int *a) { |
| 8 |
return '\0' == a; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 9 |
} |
| 10 |
|
| 11 |
int test3(int *a) { |
| 12 |
return a == L'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 13 |
} |
| 14 |
|
| 15 |
int test4(int *a) { |
| 16 |
return a == u'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 17 |
} |
| 18 |
|
| 19 |
int test5(int *a) { |
| 20 |
return a == U'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 21 |
} |
| 22 |
|
| 23 |
int test6(int *a) { |
| 24 |
return a == (char)0; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 25 |
} |
| 26 |
|
| 27 |
typedef char my_char; |
| 28 |
int test7(int *a) { |
| 29 |
return a == (my_char)0; |
| 30 |
// expected-warning@-1 {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 31 |
} |
| 32 |
|
| 33 |
int test8(int *a) { |
| 34 |
return a != '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}} |
| 35 |
} |
| 36 |
|
| 37 |
#define NULL (void *)0 |
| 38 |
int test9(int *a) { |
| 39 |
return a == '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to NULL?}} |
| 40 |
} |
| 41 |
|
| 42 |
#define MYCHAR char |
| 43 |
int test10(int *a) { |
| 44 |
return a == (MYCHAR)0; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to NULL?}} |
| 45 |
} |
| 46 |
|
| 47 |
int test11(int *a) { |
| 48 |
return a > '\0'; |
| 49 |
} |