111
|
1 // { dg-do link }
|
|
2 // { dg-options "" }
|
|
3
|
|
4 #include <cstddef>
|
|
5
|
|
6 void g(int) {}
|
|
7 void g(long) {}
|
|
8 void g(long long) {}
|
|
9 extern void g(void*);
|
|
10
|
|
11 template <int I>
|
|
12 void h() {}
|
|
13
|
|
14 void k(int) {}
|
|
15
|
|
16 template <class T>
|
|
17 void l(T);
|
|
18
|
|
19 template <>
|
|
20 void l(int) {}
|
|
21
|
|
22 template <>
|
|
23 void l(long) {}
|
|
24
|
|
25 template <>
|
|
26 void l(long long) {}
|
|
27
|
|
28 void warn_for_NULL()
|
|
29 {
|
|
30 int i = NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
31 float z = NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
32 int a[2];
|
|
33
|
|
34 i != NULL; // { dg-warning "" } NULL used in arithmetic
|
|
35 NULL != z; // { dg-warning "" } NULL used in arithmetic
|
|
36 k != NULL; // No warning: decay conversion
|
|
37 NULL != a; // Likewise.
|
|
38 -NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
39 +NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
40 ~NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
41 a[NULL] = 3; // { dg-warning "" } converting NULL to non-pointer-type
|
|
42 i = NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
43 z = NULL; // { dg-warning "" } converting NULL to non-pointer type
|
|
44 k(NULL); // { dg-warning "" } converting NULL to int
|
|
45 g(NULL); // { dg-warning "" } converting NULL to int
|
|
46 h<NULL>(); // No warning: NULL bound to integer template parameter
|
|
47 l(NULL); // No warning: NULL is used to implicitly instantiate the template
|
|
48 NULL && NULL; // No warning: converting NULL to bool is OK
|
|
49 }
|
|
50
|
131
|
51 void warn_for___null()
|
111
|
52 {
|
|
53 int i = __null; // { dg-warning "" } converting __null to non-pointer type
|
|
54 float z = __null; // { dg-warning "" } converting __null to non-pointer type
|
|
55 int a[2];
|
|
56
|
|
57 i != __null; // { dg-warning "" } __null used in arithmetic
|
|
58 __null != z; // { dg-warning "" } __null used in arithmetic
|
|
59 k != __null; // No warning: decay conversion
|
|
60 __null != a; // Likewise.
|
|
61 -__null; // { dg-warning "" } converting __null to non-pointer type
|
|
62 +__null; // { dg-warning "" } converting __null to non-pointer type
|
|
63 ~__null; // { dg-warning "" } converting __null to non-pointer type
|
|
64 a[__null] = 3; // { dg-warning "" } converting __null to non-pointer-type
|
|
65 i = __null; // { dg-warning "" } converting __null to non-pointer type
|
|
66 z = __null; // { dg-warning "" } converting __null to non-pointer type
|
|
67 k(__null); // { dg-warning "" } converting __null to int
|
|
68 g(__null); // { dg-warning "" } converting __null to int
|
|
69 h<__null>(); // No warning: __null bound to integer template parameter
|
|
70 l(__null); // No warning: __null is used to implicitly instantiate the template
|
|
71 __null && __null; // No warning: converting NULL to bool is OK
|
|
72 }
|
|
73
|
|
74 int main()
|
|
75 {
|
|
76 warn_for_NULL();
|
|
77 warn_for___null();
|
|
78 }
|