| 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 |
int i; |
| 14 |
struct S { |
| 15 |
int i; |
| 16 |
int ii; |
| 17 |
}; |
| 18 |
S s; |
| 19 |
|
| 20 |
struct F { |
| 21 |
char padding[12]; |
| 22 |
S s; |
| 23 |
}; |
| 24 |
F f; |
| 25 |
|
| 26 |
namespace std { |
| 27 |
class type_info; |
| 28 |
} |
| 29 |
|
| 30 |
struct P { |
| 31 |
int x; |
| 32 |
}; |
| 33 |
struct Q { |
| 34 |
float m; |
| 35 |
}; |
| 36 |
struct MP : P, Q { |
| 37 |
int i; |
| 38 |
}; |
| 39 |
|
| 40 |
void Test(int (&arr)[10]) { |
| 41 |
constexpr int *pi = &i; |
| 42 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit |
| 43 |
// CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=0, Path=() |
| 44 |
|
| 45 |
constexpr int *psi = &s.i; |
| 46 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psi 'int *const' constexpr cinit |
| 47 |
// CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=1, Path=({{.*}}) |
| 48 |
|
| 49 |
constexpr int *psii = &s.ii; |
| 50 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psii 'int *const' constexpr cinit |
| 51 |
// CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, HasPath=1, PathLength=1, Path=({{.*}}) |
| 52 |
|
| 53 |
constexpr int *pf = &f.s.ii; |
| 54 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pf 'int *const' constexpr cinit |
| 55 |
// CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}}) |
| 56 |
|
| 57 |
constexpr char *pc = &f.padding[2]; |
| 58 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pc 'char *const' constexpr cinit |
| 59 |
// CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, HasPath=1, PathLength=2, Path=({{.*}}, 2) |
| 60 |
|
| 61 |
constexpr const int *n = nullptr; |
| 62 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit |
| 63 |
// CHECK-NEXT: | |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=() |
| 64 |
|
| 65 |
constexpr const std::type_info* pti = &typeid(int); |
| 66 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pti 'const std::type_info *const' constexpr cinit |
| 67 |
// CHECK-NEXT: | |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=() |
| 68 |
|
| 69 |
constexpr int(MP::*pmi) = (int MP::*)&P::x; |
| 70 |
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmi 'int (MP::*const)' constexpr cinit |
| 71 |
// CHECK-NEXT: | |-value: MemberPointer MP::x |
| 72 |
|
| 73 |
constexpr int(MP::*pmn) = (int MP::*)nullptr; |
| 74 |
// CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmn 'int (MP::*const)' constexpr cinit |
| 75 |
// CHECK-NEXT: |-value: MemberPointer null |
| 76 |
} |