blob: eabfebc266d1ede2596fff452898c263a39314f3 [file] [log] [blame]
George Burgess IVa5c25c52019-08-05 23:19:15 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s -std=c11
George Burgess IVf708f0a2019-08-05 22:15:40 +00002
3int 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
7int 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
11int 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
15int 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
19int 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
23int 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
27typedef char my_char;
28int 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
33int 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
38int 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
43int 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
47int test11(int *a) {
48 return a > '\0';
49}