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