OSDN Git Service

2007-01-30 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / warn / null4.C
1 // PR c++/24745 : warnings for NULL constant.
2 // { dg-do compile  }
3 // { dg-options "-Wpointer-arith -Wconversion " }
4
5 #include <cstddef>
6
7 int foo (void) 
8 {
9   if (NULL == 1) return -1;   // { dg-warning "NULL used in arithmetic" } 
10   if (NULL > NULL) return -1; // { dg-warning "NULL used in arithmetic" } 
11   if (NULL < NULL) return -1; // { dg-warning "NULL used in arithmetic" } 
12   if (NULL >= 0) return -1;   // { dg-warning "NULL used in arithmetic" } 
13   if (NULL <= 0) return -1;   // { dg-warning "NULL used in arithmetic" } 
14   return 0;
15 }
16
17 int bar (void) 
18 {
19   if (NULL) return -1;
20   if (!NULL) return -1;
21   if (!NULL == 1) return -1;
22   if (NULL || NULL) return -1;
23   if (!NULL && NULL) return -1;
24   if (NULL == NULL) return -1;
25   if (NULL != NULL) return -1;
26   if (NULL == 0) return -1;
27   if (NULL != 0) return -1;
28   return 0;
29 }