Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wconversion-null.C

raw
1 // { dg-do link }
2 // { dg-options "-Wconversion -Wno-conversion-null -Wno-pointer-arith" }
3
4 #include <cstddef>
5
6 void g(int) {}
7 void g(long) {}
8 void g(long long) {}
9 #ifdef __MSP430X_LARGE__
10 void g(__int20) {}
11 #endif
12 extern void g(void*);
13
14 template <int I>
15 void h() {}
16
17 void k(int) {}
18
19 template <class T>
20 void l(T);
21
22 template <>
23 void l(int) {}
24
25 template <>
26 void l(long) {}
27
28 template <>
29 void l(long long) {}
30
31 #ifdef __MSP430X_LARGE__
32 template <>
33 void l(__int20) {}
34 #endif
35
36 int main()
37 {
38 int i = NULL; // converting NULL to non-pointer type
39 float z = NULL; // converting NULL to non-pointer type
40 int a[2];
41
42 i != NULL; // NULL used in arithmetic
43 NULL != z; // NULL used in arithmetic
44 k != NULL; // No warning: decay conversion
45 NULL != a; // Likewise.
46 -NULL; // converting NULL to non-pointer type
47 +NULL; // converting NULL to non-pointer type
48 ~NULL; // converting NULL to non-pointer type
49 a[NULL] = 3; // converting NULL to non-pointer-type
50 i = NULL; // converting NULL to non-pointer type
51 z = NULL; // converting NULL to non-pointer type
52 k(NULL); // converting NULL to int
53 g(NULL); // converting NULL to int
54 h<NULL>(); // No warning: NULL bound to integer template parameter
55 l(NULL); // converting NULL to int
56 NULL && NULL; // No warning: converting NULL to bool is OK
57 }