1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
3 // RUN:            -ast-dump %s -ast-dump-filter Test \
4 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
5 //
6 // Test with serialization:
7 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
8 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
9 // RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
10 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
11 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
12 
13 struct S0 {
14   int arr[2];
15 };
16 union U0 {
17   int i;
18   float f;
19 };
20 
21 struct S1 {
22   S0 s0 = {1, 2};
23   U0 u0 = {.i = 42};
24 };
25 
Test()26 void Test() {
27   constexpr int __attribute__((vector_size(sizeof(int) * 5))) arr_v5i[5] = {
28       {1, 2, 3, 4, 5},
29       {1, 2, 3, 4},
30   };
31   // CHECK:  | `-VarDecl {{.*}} <line:{{.*}}, line:{{.*}}> line:{{.*}} arr_v5i '__attribute__((__vector_size__(5 * sizeof(int)))) int const[5]' constexpr cinit
32   // CHECK-NEXT:  |   |-value: Array size=5
33   // CHECK-NEXT:  |   | |-element: Vector length=5
34   // CHECK-NEXT:  |   | | |-elements: Int 1, Int 2, Int 3, Int 4
35   // CHECK-NEXT:  |   | | `-element: Int 5
36   // CHECK-NEXT:  |   | |-element: Vector length=5
37   // CHECK-NEXT:  |   | | |-elements: Int 1, Int 2, Int 3, Int 4
38   // CHECK-NEXT:  |   | | `-element: Int 0
39   // CHECK-NEXT:  |   | `-filler: 3 x Vector length=5
40   // CHECK-NEXT:  |   |   |-elements: Int 0, Int 0, Int 0, Int 0
41   // CHECK-NEXT:  |   |   `-element: Int 0
42 
43   constexpr float arr_f[3][5] = {
44       {1, 2, 3, 4, 5},
45   };
46   // CHECK:  | `-VarDecl {{.*}} <line:{{.*}}, line:{{.*}}> line:{{.*}} arr_f 'float const[3][5]' constexpr cinit
47   // CHECK-NEXT:  |   |-value: Array size=3
48   // CHECK-NEXT:  |   | |-element: Array size=5
49   // CHECK-NEXT:  |   | | |-elements: Float 1.000000e+00, Float 2.000000e+00, Float 3.000000e+00, Float 4.000000e+00
50   // CHECK-NEXT:  |   | | `-element: Float 5.000000e+00
51   // CHECK-NEXT:  |   | `-filler: 2 x Array size=5
52   // CHECK-NEXT:  |   |   `-filler: 5 x Float 0.000000e+00
53 
54   constexpr S0 arr_s0[2] = {{1, 2}, {3, 4}};
55   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} arr_s0 'S0 const[2]' constexpr cinit
56   // CHECK-NEXT:  |   |-value: Array size=2
57   // CHECK-NEXT:  |   | |-element: Struct
58   // CHECK-NEXT:  |   | | `-field: Array size=2
59   // CHECK-NEXT:  |   | |   `-elements: Int 1, Int 2
60   // CHECK-NEXT:  |   | `-element: Struct
61   // CHECK-NEXT:  |   |   `-field: Array size=2
62   // CHECK-NEXT:  |   |     `-elements: Int 3, Int 4
63 
64   constexpr U0 arr_u0[2] = {{.i = 42}, {.f = 3.1415f}};
65   // CHECK:  | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} arr_u0 'U0 const[2]' constexpr cinit
66   // CHECK-NEXT:  |   |-value: Array size=2
67   // CHECK-NEXT:  |   | `-elements: Union .i Int 42, Union .f Float 3.141500e+00
68 
69   constexpr S1 arr_s1[2] = {};
70   // CHECK:    `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} arr_s1 'S1 const[2]' constexpr cinit
71   // CHECK-NEXT:      |-value: Array size=2
72   // CHECK-NEXT:      | |-element: Struct
73   // CHECK-NEXT:      | | |-field: Struct
74   // CHECK-NEXT:      | | | `-field: Array size=2
75   // CHECK-NEXT:      | | |   `-elements: Int 1, Int 2
76   // CHECK-NEXT:      | | `-field: Union .i Int 42
77   // CHECK-NEXT:      | `-element: Struct
78   // CHECK-NEXT:      |   |-field: Struct
79   // CHECK-NEXT:      |   | `-field: Array size=2
80   // CHECK-NEXT:      |   |   `-elements: Int 1, Int 2
81   // CHECK-NEXT:      |   `-field: Union .i Int 42
82 }
83