annotate clang/test/AST/ast-dump-APValue-union.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 // Test without serialization:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // RUN: -ast-dump %s -ast-dump-filter Test \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // Test with serialization:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 // RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 union U0 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 int i = 42;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 float f;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 union U1 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 union Uinner {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 int i;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 float f = 3.1415f;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 } uinner;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 union U2 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 union Uinner {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 double d;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 int arr[2] = {1, 2};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 } uinner;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 union U3 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 union Uinner {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 double d = 3.1415;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 int arr[2];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 } uinner;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 float f;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 void Test() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 constexpr U0 u0{};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} u0 'const U0' constexpr listinit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 // CHECK-NEXT: | |-value: Union .i Int 42
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 constexpr U1 u1{};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} u1 'const U1' constexpr listinit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 // CHECK-NEXT: | |-value: Union .uinner Union .f Float 3.141500e+00
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 constexpr U2 u2{};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} u2 'const U2' constexpr listinit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 // CHECK-NEXT: | |-value: Union .uinner
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 // CHECK-NEXT: | | `-Union .arr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // CHECK-NEXT: | | `-Array size=2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 // CHECK-NEXT: | | `-elements: Int 1, Int 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 constexpr U3 u3a = {.f = 3.1415};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} u3a 'const U3' constexpr cinit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 // CHECK-NEXT: | |-value: Union .f Float 3.141500e+00
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 constexpr U3 u3b = {.uinner = {}};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 // CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} u3b 'const U3' constexpr cinit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 // CHECK-NEXT: |-value: Union .uinner Union .d Float 3.141500e+00
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 }