| 1 |
// PR c++/19808 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-Wuninitialized" } |
| 4 |
|
| 5 |
class AllocatorWithCleanup { |
| 6 |
public: |
| 7 |
int *allocate(int); |
| 8 |
}; |
| 9 |
class SecBlock { |
| 10 |
SecBlock() : m_ptr(m_alloc.allocate(0)) {} // { dg-bogus "uninitialized" } |
| 11 |
AllocatorWithCleanup m_alloc; |
| 12 |
int *m_ptr; |
| 13 |
}; |
| 14 |
|
| 15 |
struct A { |
| 16 |
int *allocate(int); |
| 17 |
}; |
| 18 |
|
| 19 |
struct B { |
| 20 |
int : 0; |
| 21 |
int *allocate(int); |
| 22 |
}; |
| 23 |
|
| 24 |
struct C : B { |
| 25 |
}; |
| 26 |
|
| 27 |
struct D { |
| 28 |
char arr[0]; |
| 29 |
int *allocate(int); |
| 30 |
}; |
| 31 |
|
| 32 |
struct E { }; |
| 33 |
|
| 34 |
struct F { |
| 35 |
E arr[10]; |
| 36 |
int *allocate(int); |
| 37 |
}; |
| 38 |
|
| 39 |
struct G { |
| 40 |
E e; |
| 41 |
int *allocate(int); |
| 42 |
}; |
| 43 |
|
| 44 |
struct H { |
| 45 |
virtual void foo (); |
| 46 |
int *allocate(int); |
| 47 |
}; |
| 48 |
|
| 49 |
template<typename T> |
| 50 |
struct X { |
| 51 |
X() : m_ptr(t.allocate(0)) {} // { dg-bogus "uninitialized" } |
| 52 |
T t; |
| 53 |
int *m_ptr; |
| 54 |
}; |
| 55 |
|
| 56 |
struct V { |
| 57 |
int a; |
| 58 |
int *allocate(int); |
| 59 |
}; |
| 60 |
|
| 61 |
struct Z { |
| 62 |
Z() : m_ptr(v.allocate(0)) {} // { dg-warning "uninitialized" } |
| 63 |
V v; |
| 64 |
int *m_ptr; |
| 65 |
}; |
| 66 |
|
| 67 |
X<A> x1; |
| 68 |
X<B> x2; |
| 69 |
X<C> x3; |
| 70 |
X<D> x4; |
| 71 |
X<F> x5; |
| 72 |
X<G> x6; |
| 73 |
X<H> x7; |