114 lines · cpp
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 %s5//6// Test with serialization:7// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s8// 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 %s12 13struct S0 {14 int i = 0;15 union {16 int j = 0;17 } u0;18};19 20struct S1 {21 int i = 0;22 union {23 struct {24 int j = 0;25 } s;26 } u1;27};28 29struct S2 {30 int i = 0;31 union {32 union {33 int j = 0;34 } u;35 } u2;36};37 38struct S3 {39 int i = 0;40 union {41 union {42 struct {43 int j = 0;44 } j;45 } u;46 } u3;47};48 49struct S4 : S0 {50 int i = 1, j = 2, k = 3;51 struct {52 } s;53 int a = 4, b = 5, c = 6;54};55 56struct S5 : S4 {57 int arr0[8] = {1, 2, 3, 4};58 int arr1[8] = {1, 2, 3, 4, 0, 0, 0, 0};59};60 61void Test() {62 constexpr S0 s0{};63 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s0 'const S0' constexpr listinit64 // CHECK-NEXT: | |-value: Struct65 // CHECK-NEXT: | | `-fields: Int 0, Union .j Int 066 67 constexpr S1 s1{};68 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s1 'const S1' constexpr listinit69 // CHECK-NEXT: | |-value: Struct70 // CHECK-NEXT: | | |-field: Int 071 // CHECK-NEXT: | | `-field: Union .s72 // CHECK-NEXT: | | `-Struct73 // CHECK-NEXT: | | `-field: Int 074 75 constexpr S2 s2{};76 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s2 'const S2' constexpr listinit77 // CHECK-NEXT: | |-value: Struct78 // CHECK-NEXT: | | `-fields: Int 0, Union .u Union .j Int 079 80 constexpr S3 s3{};81 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s3 'const S3' constexpr listinit82 // CHECK-NEXT: | |-value: Struct83 // CHECK-NEXT: | | |-field: Int 084 // CHECK-NEXT: | | `-field: Union .u85 // CHECK-NEXT: | | `-Union .j86 // CHECK-NEXT: | | `-Struct87 // CHECK-NEXT: | | `-field: Int 088 89 constexpr S4 s4{};90 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s4 'const S4' constexpr listinit91 // CHECK-NEXT: | |-value: Struct92 // CHECK-NEXT: | | |-base: Struct93 // CHECK-NEXT: | | | `-fields: Int 0, Union .j Int 094 // CHECK-NEXT: | | |-fields: Int 1, Int 2, Int 395 // CHECK-NEXT: | | |-field: Struct96 // CHECK-NEXT: | | `-fields: Int 4, Int 5, Int 697 98 constexpr S5 s5{};99 // CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} s5 'const S5' constexpr listinit100 // CHECK-NEXT: |-value: Struct101 // CHECK-NEXT: | |-base: Struct102 // CHECK-NEXT: | | |-base: Struct103 // CHECK-NEXT: | | | `-fields: Int 0, Union .j Int 0104 // CHECK-NEXT: | | |-fields: Int 1, Int 2, Int 3105 // CHECK-NEXT: | | |-field: Struct106 // CHECK-NEXT: | | `-fields: Int 4, Int 5, Int 6107 // CHECK-NEXT: | |-field: Array size=8108 // CHECK-NEXT: | | |-elements: Int 1, Int 2, Int 3, Int 4109 // CHECK-NEXT: | | `-filler: 4 x Int 0110 // CHECK-NEXT: | `-field: Array size=8111 // CHECK-NEXT: | |-elements: Int 1, Int 2, Int 3, Int 4112 // CHECK-NEXT: | `-elements: Int 0, Int 0, Int 0, Int 0113}114