| 1 |
// PR c++/90992 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-additional-options -Wnoexcept } |
| 4 |
|
| 5 |
#include "Wnoexcept1.h" |
| 6 |
|
| 7 |
// We expect a warning at the declaration of construct2, since Automatic2 is |
| 8 |
// defined below; we don't expect one for construct1, because Automatic1 is |
| 9 |
// defined in the fake system header. |
| 10 |
// { dg-warning "noexcept-expression" "" { target *-*-* } 16 } |
| 11 |
|
| 12 |
class Automatic2 { |
| 13 |
public: |
| 14 |
Automatic2(size_t bla) : Bla(bla) {}; // { dg-message "noexcept" } |
| 15 |
|
| 16 |
private: |
| 17 |
size_t Bla; |
| 18 |
}; |
| 19 |
|
| 20 |
union U |
| 21 |
{ |
| 22 |
unsigned char buf[sizeof(Automatic1)]; |
| 23 |
Automatic1 a1; |
| 24 |
Automatic2 a2; |
| 25 |
U(): buf{} {} |
| 26 |
~U() {} |
| 27 |
}; |
| 28 |
|
| 29 |
int main() { |
| 30 |
U u; |
| 31 |
construct1(&u.a1, 42); |
| 32 |
construct2(&u.a2, 42); |
| 33 |
} |