* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / c-c++-common / Wpointer-compare-1.c
blob440341ed9edec35252542bc4632b225d9de68c7f
1 /* PR c++/64767 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wpointer-compare" } */
4 /* { dg-additional-options "-std=c++03" { target c++ } } */
6 int
7 f1 (int *p, int **q)
9 int r = 0;
11 r += p == '\0'; /* { dg-warning "comparison between pointer and zero character" } */
12 r += p == L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
13 r += p != '\0'; /* { dg-warning "comparison between pointer and zero character" } */
14 r += p != L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
16 r += '\0' == p; /* { dg-warning "comparison between pointer and zero character" } */
17 r += L'\0' == p; /* { dg-warning "comparison between pointer and zero character" } */
18 r += '\0' != p; /* { dg-warning "comparison between pointer and zero character" } */
19 r += L'\0' != p; /* { dg-warning "comparison between pointer and zero character" } */
21 r += q == '\0'; /* { dg-warning "comparison between pointer and zero character" } */
22 r += q == L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
23 r += q != '\0'; /* { dg-warning "comparison between pointer and zero character" } */
24 r += q != L'\0'; /* { dg-warning "comparison between pointer and zero character" } */
26 r += '\0' == q; /* { dg-warning "comparison between pointer and zero character" } */
27 r += L'\0' == q; /* { dg-warning "comparison between pointer and zero character" } */
28 r += '\0' != q; /* { dg-warning "comparison between pointer and zero character" } */
29 r += L'\0' != q; /* { dg-warning "comparison between pointer and zero character" } */
31 return r;
34 int
35 f2 (int *p)
37 int r = 0;
39 /* Keep quiet. */
40 r += p == (void *) 0;
41 r += p != (void *) 0;
42 r += (void *) 0 == p;
43 r += (void *) 0 != p;
45 r += p == 0;
46 r += p != 0;
47 r += 0 == p;
48 r += 0 != p;
50 return r;
53 int
54 f3 (int *p)
56 int r = 0;
58 r += p == (char) 0; /* { dg-warning "comparison between pointer and zero character" } */
59 r += p != (char) 0; /* { dg-warning "comparison between pointer and zero character" } */
61 r += (char) 0 == p; /* { dg-warning "comparison between pointer and zero character" } */
62 r += (char) 0 != p; /* { dg-warning "comparison between pointer and zero character" } */
64 return r;