gcc/testsuite/g++.dg/warn/Wnonnull-compare-3.C
raw| 1 | // PR c++/69850 |
| 2 | // { dg-do compile } |
| 3 | // { dg-options "-Wnonnull-compare" } |
| 4 | |
| 5 | template <typename T> |
| 6 | struct A { |
| 7 | static void foo (T *x) { x->bar (); } |
| 8 | }; |
| 9 | template <typename T> |
| 10 | struct B { |
| 11 | T b; |
| 12 | void operator= (B) { A<T>::foo (&b); } |
| 13 | }; |
| 14 | struct C { |
| 15 | void bar () { delete[] this; } // { dg-bogus "nonnull argument" } |
| 16 | }; |
| 17 | struct D { B<C> d; }; |
| 18 | struct G { |
| 19 | D g[6]; |
| 20 | void baz (); |
| 21 | }; |
| 22 | int a; |
| 23 | |
| 24 | void |
| 25 | G::baz () |
| 26 | { |
| 27 | g[a] = g[1]; |
| 28 | } |