| 1 |
/* PR middle-end/104076 - bogus -Wdangling-pointer on a conditional expression |
| 2 |
{ dg-do compile { target { c++11 } } } |
| 3 |
{ dg-options "-Wall" } */ |
| 4 |
|
| 5 |
namespace std { |
| 6 |
|
| 7 |
template <class T> |
| 8 |
struct initializer_list |
| 9 |
{ |
| 10 |
T *array; |
| 11 |
__SIZE_TYPE__ nelts; |
| 12 |
|
| 13 |
initializer_list (const T *a, __SIZE_TYPE__ n) |
| 14 |
: array (a), nelts (n) { } |
| 15 |
|
| 16 |
initializer_list() |
| 17 |
: array (), nelts () { } |
| 18 |
|
| 19 |
T* begin () const { return array; } |
| 20 |
|
| 21 |
const T* end () const { return array + nelts; } |
| 22 |
}; |
| 23 |
|
| 24 |
} |
| 25 |
|
| 26 |
struct S1 |
| 27 |
{ |
| 28 |
S1 (int); |
| 29 |
~S1 (); |
| 30 |
}; |
| 31 |
|
| 32 |
struct S2 { S2 (std::initializer_list<S1>); }; |
| 33 |
|
| 34 |
S2 f1(); |
| 35 |
|
| 36 |
S2 f2(bool b) |
| 37 |
{ |
| 38 |
return b ? f1() : S2{0}; // { dg-bogus "-Wdangling-pointer" } |
| 39 |
} |