Merge from mainline
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / null1.C
blob536f759e6a197fed3107d37be47f97659f50510f
1 // { dg-do link  }
2 // { dg-options "-Wconversion" }
4 #include <cstddef>
6 void g(int) {}
7 void g(long) {}
8 extern void g(void*);
10 template <int I>
11 void h() {}
13 void k(int) {}
15 template <class T>
16 void l(T);
18 template <>
19 void l(int) {}
21 template <>
22 void l(long) {}
24 int main()
26   int i = NULL; // { dg-warning "" } converting NULL to non-pointer type
27   float z = NULL; // { dg-warning "" } converting NULL to non-pointer type
28   int a[2];
30   i != NULL; // { dg-warning "" } NULL used in arithmetic
31   NULL != z; // { dg-warning "" } NULL used in arithmetic
32   k != NULL; // No warning: decay conversion
33   NULL != a; // Likewise.
34   -NULL;     // { dg-warning "" } converting NULL to non-pointer type
35   +NULL;     // { dg-warning "" } converting NULL to non-pointer type
36   ~NULL;     // { dg-warning "" } converting NULL to non-pointer type
37   a[NULL] = 3; // { dg-warning "" } converting NULL to non-pointer-type
38   i = NULL;  // { dg-warning "" } converting NULL to non-pointer type
39   z = NULL;  // { dg-warning "" } converting NULL to non-pointer type
40   k(NULL);   // { dg-warning "" } converting NULL to int
41   g(NULL);   // { dg-warning "" } converting NULL to int
42   h<NULL>(); // No warning: NULL bound to integer template parameter
43   l(NULL);   // { dg-warning "" } converting NULL to int
44   NULL && NULL; // No warning: converting NULL to bool is OK