1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
2 // RUN:            -ast-dump %s -ast-dump-filter Test \
3 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
4 
5 struct S0 {
6   int i = 0;
7   union {
8     int j = 0;
9   } u0;
10 };
11 
12 struct S1 {
13   int i = 0;
14   union {
15     struct {
16       int j = 0;
17     } s;
18   } u1;
19 };
20 
21 struct S2 {
22   int i = 0;
23   union {
24     union {
25       int j = 0;
26     } u;
27   } u2;
28 };
29 
30 struct S3 {
31   int i = 0;
32   union {
33     union {
34       struct {
35         int j = 0;
36       } j;
37     } u;
38   } u3;
39 };
40 
41 struct S4 : S0 {
42   int i = 1, j = 2, k = 3;
43   struct {
44   } s;
45   int a = 4, b = 5, c = 6;
46 };
47 
48 struct S5 : S4 {
49   int arr0[8] = {1, 2, 3, 4};
50   int arr1[8] = {1, 2, 3, 4, 0, 0, 0, 0};
51 };
52 
53 void Test() {
54   constexpr S0 s0{};
55   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s0 'const S0' constexpr listinit
56   // CHECK-NEXT:  |   |-value: Struct
57   // CHECK-NEXT:  |   | `-fields: Int 0, Union .j Int 0
58 
59   constexpr S1 s1{};
60   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s1 'const S1' constexpr listinit
61   // CHECK-NEXT:  |   |-value: Struct
62   // CHECK-NEXT:  |   | |-field: Int 0
63   // CHECK-NEXT:  |   | `-field: Union .s
64   // CHECK-NEXT:  |   |   `-Struct
65   // CHECK-NEXT:  |   |     `-field: Int 0
66 
67   constexpr S2 s2{};
68   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s2 'const S2' constexpr listinit
69   // CHECK-NEXT:  |   |-value: Struct
70   // CHECK-NEXT:  |   | `-fields: Int 0, Union .u Union .j Int 0
71 
72   constexpr S3 s3{};
73   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s3 'const S3' constexpr listinit
74   // CHECK-NEXT:  |   |-value: Struct
75   // CHECK-NEXT:  |   | |-field: Int 0
76   // CHECK-NEXT:  |   | `-field: Union .u
77   // CHECK-NEXT:  |   |   `-Union .j
78   // CHECK-NEXT:  |   |     `-Struct
79   // CHECK-NEXT:  |   |       `-field: Int 0
80 
81   constexpr S4 s4{};
82   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s4 'const S4' constexpr listinit
83   // CHECK-NEXT:  |   |-value: Struct
84   // CHECK-NEXT:  |   | |-base: Struct
85   // CHECK-NEXT:  |   | | `-fields: Int 0, Union .j Int 0
86   // CHECK-NEXT:  |   | |-fields: Int 1, Int 2, Int 3
87   // CHECK-NEXT:  |   | |-field: Struct
88   // CHECK-NEXT:  |   | `-fields: Int 4, Int 5, Int 6
89 
90   constexpr S5 s5{};
91   // CHECK:    `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s5 'const S5' constexpr listinit
92   // CHECK-NEXT:      |-value: Struct
93   // CHECK-NEXT:      | |-base: Struct
94   // CHECK-NEXT:      | | |-base: Struct
95   // CHECK-NEXT:      | | | `-fields: Int 0, Union .j Int 0
96   // CHECK-NEXT:      | | |-fields: Int 1, Int 2, Int 3
97   // CHECK-NEXT:      | | |-field: Struct
98   // CHECK-NEXT:      | | `-fields: Int 4, Int 5, Int 6
99   // CHECK-NEXT:      | |-field: Array size=8
100   // CHECK-NEXT:      | | |-elements: Int 1, Int 2, Int 3, Int 4
101   // CHECK-NEXT:      | | `-filler: 4 x Int 0
102   // CHECK-NEXT:      | `-field: Array size=8
103   // CHECK-NEXT:      |   |-elements: Int 1, Int 2, Int 3, Int 4
104   // CHECK-NEXT:      |   `-elements: Int 0, Int 0, Int 0, Int 0
105 }
106