Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-union5.C
1 // PR c++/54922
2 // { dg-options "-std=c++11 -pedantic" }
3
4 #define SA(X) static_assert(X,#X)
5
6 struct A
7 {
8   union {
9     union {
10       union {
11         unsigned char i;
12         int j;
13       };
14     };
15   };
16
17   constexpr A() : i(42) {}
18 };
19
20 constexpr A a;
21 SA((a.i == 42));
22
23 struct B
24 {
25   struct {
26     int h;
27     struct {
28       union {
29         unsigned char i;
30         int j;
31       };
32       int k;
33     };                          // { dg-warning "anonymous struct" }
34   };                            // { dg-warning "anonymous struct" }
35   int l;
36
37   constexpr B(): h(1), i(2), k(3), l(4) {}
38 };
39
40 constexpr B b;
41 SA((b.h == 1 && b.i == 2 && b.k == 3 && b.l == 4));