1 // Test without serialization:
2 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s \
3 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
5 // Test with serialization:
6 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c++ -std=c++20 -triple x86_64-unknown-unknown -include-pch %t \
8 // RUN: -ast-dump-all -ast-dump-filter Test /dev/null \
9 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
10 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
12 // FIXME: ASTRecordReader::readAPValue and ASTRecordWriter::AddAPValue
13 // just give up on some APValue kinds! This *really* should be fixed.
33 consteval
int test_Int() { return 42; }
34 consteval
float test_Float() { return 1.0f
; }
35 consteval _Complex
int test_ComplexInt() { return 1+2i
; }
36 consteval _Complex
float test_ComplexFloat() { return 1.2f
+3.4fi
; }
37 consteval __int128
test_Int128() { return (__int128
)0xFFFFFFFFFFFFFFFF + (__int128
)1; }
38 // FIXME: consteval array_holder test_Array() { return array_holder(); }
39 // FIXME: consteval S test_Struct() { return S(); }
40 // FIXME: consteval U test_Union() { return U(); }
41 // FIXME: consteval SU test_SU() { return SU(); }
47 (void)test_ComplexInt();
48 (void)test_ComplexFloat();
50 //(void) test_Array();
51 //(void) test_Struct();
52 //(void) test_Union();
56 consteval
void consteval_method() {}
59 // CHECK:Dumping Test:
60 // CHECK-NEXT:CXXRecordDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:43:1, line:57:1> line:43:8 struct Test definition
61 // CHECK:|-CXXMethodDecl {{.*}} <line:44:3, line:54:3> line:44:8 test 'void ()' implicit-inline
62 // CHECK-NEXT:| `-CompoundStmt {{.*}} <col:15, line:54:3>
63 // CHECK-NEXT:| |-CStyleCastExpr {{.*}} <line:45:5, col:20> 'void' <ToVoid>
64 // CHECK-NEXT:| | `-ConstantExpr {{.*}} <col:11, col:20> 'int'
65 // CHECK-NEXT:| | |-value: Int 42
66 // CHECK-NEXT:| | `-CallExpr {{.*}} <col:11, col:20> 'int'
67 // CHECK-NEXT:| | `-ImplicitCastExpr {{.*}} <col:11> 'int (*)()' <FunctionToPointerDecay>
68 // CHECK-NEXT:| | `-DeclRefExpr {{.*}} <col:11> 'int ()' lvalue Function {{.*}} 'test_Int' 'int ()'
69 // CHECK-NEXT:| |-CStyleCastExpr {{.*}} <line:46:5, col:22> 'void' <ToVoid>
70 // CHECK-NEXT:| | `-ConstantExpr {{.*}} <col:11, col:22> 'float'
71 // CHECK-NEXT:| | |-value: Float 1.000000e+00
72 // CHECK-NEXT:| | `-CallExpr {{.*}} <col:11, col:22> 'float'
73 // CHECK-NEXT:| | `-ImplicitCastExpr {{.*}} <col:11> 'float (*)()' <FunctionToPointerDecay>
74 // CHECK-NEXT:| | `-DeclRefExpr {{.*}} <col:11> 'float ()' lvalue Function {{.*}} 'test_Float' 'float ()'
75 // CHECK-NEXT:| |-CStyleCastExpr {{.*}} <line:47:5, col:27> 'void' <ToVoid>
76 // CHECK-NEXT:| | `-ConstantExpr {{.*}} <col:11, col:27> '_Complex int'
77 // CHECK-NEXT:| | |-value: ComplexInt 1 + 2i
78 // CHECK-NEXT:| | `-CallExpr {{.*}} <col:11, col:27> '_Complex int'
79 // CHECK-NEXT:| | `-ImplicitCastExpr {{.*}} <col:11> '_Complex int (*)()' <FunctionToPointerDecay>
80 // CHECK-NEXT:| | `-DeclRefExpr {{.*}} <col:11> '_Complex int ()' lvalue Function {{.*}} 'test_ComplexInt' '_Complex int ()'
81 // CHECK-NEXT:| |-CStyleCastExpr {{.*}} <line:48:5, col:29> 'void' <ToVoid>
82 // CHECK-NEXT:| | `-ConstantExpr {{.*}} <col:11, col:29> '_Complex float'
83 // CHECK-NEXT:| | |-value: ComplexFloat 1.200000e+00 + 3.400000e+00i
84 // CHECK-NEXT:| | `-CallExpr {{.*}} <col:11, col:29> '_Complex float'
85 // CHECK-NEXT:| | `-ImplicitCastExpr {{.*}} <col:11> '_Complex float (*)()' <FunctionToPointerDecay>
86 // CHECK-NEXT:| | `-DeclRefExpr {{.*}} <col:11> '_Complex float ()' lvalue Function {{.*}} 'test_ComplexFloat' '_Complex float ()'
87 // CHECK-NEXT:| `-CStyleCastExpr {{.*}} <line:49:5, col:23> 'void' <ToVoid>
88 // CHECK-NEXT:| `-ConstantExpr {{.*}} <col:11, col:23> '__int128'
89 // CHECK-NEXT:| |-value: Int 18446744073709551616
90 // CHECK-NEXT:| `-CallExpr {{.*}} <col:11, col:23> '__int128'
91 // CHECK-NEXT:| `-ImplicitCastExpr {{.*}} <col:11> '__int128 (*)()' <FunctionToPointerDecay>
92 // CHECK-NEXT:| `-DeclRefExpr {{.*}} <col:11> '__int128 ()' lvalue Function {{.*}} 'test_Int128' '__int128 ()'
93 // CHECK-NEXT:`-CXXMethodDecl {{.*}} <line:56:3, col:38> col:18 consteval consteval_method 'void ()' implicit-inline