| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-options "-Wzero-as-null-pointer-constant" } |
| 3 |
|
| 4 |
struct A; |
| 5 |
|
| 6 |
typedef int (A::*pointmemfun) (int); |
| 7 |
typedef int (A::*pointdmem); |
| 8 |
typedef int (*pointfun) (int); |
| 9 |
|
| 10 |
pointmemfun pmfs; |
| 11 |
pointdmem pdms; |
| 12 |
pointfun pfs; |
| 13 |
int* ps; |
| 14 |
|
| 15 |
void f() |
| 16 |
{ |
| 17 |
pointmemfun pmf(0); // { dg-warning "zero as null pointer" } |
| 18 |
pointdmem pdm(0); // { dg-warning "zero as null pointer" } |
| 19 |
pointfun pf(0); // { dg-warning "zero as null pointer" } |
| 20 |
int* p(0); // { dg-warning "zero as null pointer" } |
| 21 |
|
| 22 |
pointmemfun pmfn(nullptr); |
| 23 |
pointdmem pdmn(nullptr); |
| 24 |
pointfun pfn(nullptr); |
| 25 |
int* pn(nullptr); |
| 26 |
|
| 27 |
pmf = 0; // { dg-warning "zero as null pointer" } |
| 28 |
|
| 29 |
pdm = 0; // { dg-warning "zero as null pointer" } |
| 30 |
|
| 31 |
pf = 0; // { dg-warning "zero as null pointer" } |
| 32 |
|
| 33 |
p = 0; // { dg-warning "zero as null pointer" } |
| 34 |
|
| 35 |
pmf = nullptr; |
| 36 |
|
| 37 |
pdm = nullptr; |
| 38 |
|
| 39 |
pf = nullptr; |
| 40 |
|
| 41 |
p = nullptr; |
| 42 |
|
| 43 |
if (pmf) |
| 44 |
; |
| 45 |
|
| 46 |
if (pdm) |
| 47 |
; |
| 48 |
|
| 49 |
if (pf) |
| 50 |
; |
| 51 |
|
| 52 |
if (p) |
| 53 |
; |
| 54 |
|
| 55 |
if (!pmf) |
| 56 |
; |
| 57 |
|
| 58 |
if (!pdm) |
| 59 |
; |
| 60 |
|
| 61 |
if (!pf) |
| 62 |
; |
| 63 |
|
| 64 |
if (!p) |
| 65 |
; |
| 66 |
|
| 67 |
if (pmf == 0) // { dg-warning "14: zero as null pointer" } |
| 68 |
; |
| 69 |
|
| 70 |
if (pdm == 0) // { dg-warning "14: zero as null pointer" } |
| 71 |
; |
| 72 |
|
| 73 |
if (pf == 0) // { dg-warning "13: zero as null pointer" } |
| 74 |
; |
| 75 |
|
| 76 |
if (p == 0) // { dg-warning "12: zero as null pointer" } |
| 77 |
; |
| 78 |
|
| 79 |
if (0 == pmf) // { dg-warning "zero as null pointer" } |
| 80 |
; |
| 81 |
|
| 82 |
if (0 == pdm) // { dg-warning "zero as null pointer" } |
| 83 |
; |
| 84 |
|
| 85 |
if (0 == pf) // { dg-warning "zero as null pointer" } |
| 86 |
; |
| 87 |
|
| 88 |
if (0 == p) // { dg-warning "zero as null pointer" } |
| 89 |
; |
| 90 |
|
| 91 |
if (pmf != 0) // { dg-warning "zero as null pointer" } |
| 92 |
; |
| 93 |
|
| 94 |
if (pdm != 0) // { dg-warning "zero as null pointer" } |
| 95 |
; |
| 96 |
|
| 97 |
if (pf != 0) // { dg-warning "zero as null pointer" } |
| 98 |
; |
| 99 |
|
| 100 |
if (p != 0) // { dg-warning "zero as null pointer" } |
| 101 |
; |
| 102 |
|
| 103 |
if (0 != pmf) // { dg-warning "zero as null pointer" } |
| 104 |
; |
| 105 |
|
| 106 |
if (0 != pdm) // { dg-warning "zero as null pointer" } |
| 107 |
; |
| 108 |
|
| 109 |
if (0 != pf) // { dg-warning "zero as null pointer" } |
| 110 |
; |
| 111 |
|
| 112 |
if (0 != p) // { dg-warning "zero as null pointer" } |
| 113 |
; |
| 114 |
|
| 115 |
if (pmf == nullptr) |
| 116 |
; |
| 117 |
|
| 118 |
if (pdm == nullptr) |
| 119 |
; |
| 120 |
|
| 121 |
if (pf == nullptr) |
| 122 |
; |
| 123 |
|
| 124 |
if (p == nullptr) |
| 125 |
; |
| 126 |
|
| 127 |
if (nullptr == pmf) |
| 128 |
; |
| 129 |
|
| 130 |
if (nullptr == pdm) |
| 131 |
; |
| 132 |
|
| 133 |
if (nullptr == pf) |
| 134 |
; |
| 135 |
|
| 136 |
if (nullptr == p) |
| 137 |
; |
| 138 |
|
| 139 |
if (pmf != nullptr) |
| 140 |
; |
| 141 |
|
| 142 |
if (pdm != nullptr) |
| 143 |
; |
| 144 |
|
| 145 |
if (pf != nullptr) |
| 146 |
; |
| 147 |
|
| 148 |
if (p != nullptr) |
| 149 |
; |
| 150 |
|
| 151 |
if (nullptr != pmf) |
| 152 |
; |
| 153 |
|
| 154 |
if (nullptr != pdm) |
| 155 |
; |
| 156 |
|
| 157 |
if (nullptr != pf) |
| 158 |
; |
| 159 |
|
| 160 |
if (nullptr != p) |
| 161 |
; |
| 162 |
} |