1 // PR c++/24745 : warnings for NULL constant.
3 // { dg-options "-Wpointer-arith -Wconversion " }
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 // Adding to the NULL pointer, which has no specific type, should
15 // result in a warning; the type of the resulting expression is
16 // actually "int", not a pointer type.
17 if (NULL + 1) return -1; // { dg-warning "NULL used in arithmetic" }
18 if (1 + NULL) return -1; // { dg-warning "NULL used in arithmetic" }
26 typedef void (S::*SPF)(void);
34 if (!NULL == 1) return -1;
35 if (NULL || NULL) return -1;
36 if (!NULL && NULL) return -1;
37 if (NULL == NULL) return -1;
38 if (NULL != NULL) return -1;
39 if (NULL == 0) return -1;
40 if (NULL != 0) return -1;
41 // Subtraction of pointers is vaild, so using NULL is OK.
42 if (ip - NULL) return -1;
43 if (NULL - NULL) return -1;
44 // Comparing NULL with a pointer-to-member is OK.
45 if (NULL == spd) return -1;
46 if (spd == NULL) return -1;
47 if (NULL != spd) return -1;
48 if (spd != NULL) return -1;
49 if (NULL == spf) return -1;
50 if (spf == NULL) return -1;
51 if (NULL != spf) return -1;
52 if (spf != NULL) return -1;