1 | // Test this without pch. |
2 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump | FileCheck %s |
3 | |
4 | // Test with pch. Use '-ast-dump' to force deserialization of function bodies. |
5 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx_exprs.h |
6 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump-all | FileCheck %s |
7 | |
8 | // expected-no-diagnostics |
9 | |
10 | int integer; |
11 | double floating; |
12 | char character; |
13 | bool boolean; |
14 | |
15 | // CXXStaticCastExpr |
16 | static_cast_result void_ptr = &integer; |
17 | // CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}}{{(imported)?}} referenced static_cast_result 'typeof (static_cast<void *>(0))':'void *'{{$}} |
18 | // CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (static_cast<void *>(0))' sugar{{( imported)?}}{{$}} |
19 | // CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *'{{$}} |
20 | // CHECK-NEXT: CXXStaticCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *' static_cast<void *> <NoOp>{{$}} |
21 | // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'void *' <NullToPointer> part_of_explicit_cast{{$}} |
22 | // CHECK-NEXT: IntegerLiteral {{.*}} <col:{{.*}}> 'int' 0{{$}} |
23 | |
24 | // CXXDynamicCastExpr |
25 | Derived *d; |
26 | dynamic_cast_result derived_ptr = d; |
27 | // CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced dynamic_cast_result 'typeof (dynamic_cast<Derived *>(base_ptr))':'Derived *'{{$}} |
28 | // CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (dynamic_cast<Derived *>(base_ptr))' sugar{{( imported)?}}{{$}} |
29 | // CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'Derived *'{{$}} |
30 | // CHECK-NEXT: CXXDynamicCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'Derived *' dynamic_cast<struct Derived *> <Dynamic>{{$}} |
31 | // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'Base *' <LValueToRValue> part_of_explicit_cast{{$}} |
32 | // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'Base *' lvalue Var {{.*}} 'base_ptr' 'Base *'{{$}} |
33 | |
34 | // CXXReinterpretCastExpr |
35 | reinterpret_cast_result void_ptr2 = &integer; |
36 | // CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced reinterpret_cast_result 'typeof (reinterpret_cast<void *>(0))':'void *'{{$}} |
37 | // CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (reinterpret_cast<void *>(0))' sugar{{( imported)?}}{{$}} |
38 | // CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *'{{$}} |
39 | // CHECK-NEXT: CXXReinterpretCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'void *' reinterpret_cast<void *> <IntegralToPointer>{{$}} |
40 | // CHECK-NEXT: IntegerLiteral {{.*}} <col:{{.*}}> 'int' 0{{$}} |
41 | |
42 | // CXXConstCastExpr |
43 | const_cast_result char_ptr = &character; |
44 | // CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced const_cast_result 'typeof (const_cast<char *>(const_char_ptr_value))':'char *'{{$}} |
45 | // CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (const_cast<char *>(const_char_ptr_value))' sugar{{( imported)?}}{{$}} |
46 | // CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'char *'{{$}} |
47 | // CHECK-NEXT: CXXConstCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'char *' const_cast<char *> <NoOp>{{$}} |
48 | // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'const char *' <LValueToRValue> part_of_explicit_cast{{$}} |
49 | // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'const char *' lvalue Var {{.*}} 'const_char_ptr_value' 'const char *'{{$}} |
50 | |
51 | // CXXFunctionalCastExpr |
52 | functional_cast_result *double_ptr = &floating; |
53 | // CHECK: TypedefDecl {{.*}} <{{.*}}, col:{{.*}}> col:{{.*}} referenced functional_cast_result 'typeof (double(int_value))':'double'{{$}} |
54 | // CHECK-NEXT: TypeOfExprType {{.*}} 'typeof (double(int_value))' sugar{{( imported)?}}{{$}} |
55 | // CHECK-NEXT: ParenExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'double'{{$}} |
56 | // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} <col:{{.*}}, col:{{.*}}> 'double' functional cast to double <NoOp>{{$}} |
57 | // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'double' <IntegralToFloating> part_of_explicit_cast{{$}} |
58 | // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:{{.*}}> 'int' <LValueToRValue> part_of_explicit_cast{{$}} |
59 | // CHECK-NEXT: DeclRefExpr {{.*}} <col:{{.*}}> 'int' lvalue Var {{.*}} 'int_value' 'int'{{$}} |
60 | |
61 | // CXXBoolLiteralExpr |
62 | bool_literal_result *bool_ptr = &boolean; |
63 | static_assert(true_value, "true_value is true"); |
64 | static_assert(!false_value, "false_value is false"); |
65 | |
66 | // CXXNullPtrLiteralExpr |
67 | cxx_null_ptr_result null_ptr = nullptr; |
68 | |
69 | // CXXTypeidExpr |
70 | typeid_result1 typeid_1 = 0; |
71 | typeid_result2 typeid_2 = 0; |
72 | |
73 | // CharacterLiteral variants |
74 | static_assert(char_value == 97, "char_value is correct"); |
75 | static_assert(wchar_t_value == 305, "wchar_t_value is correct"); |
76 | static_assert(char16_t_value == 231, "char16_t_value is correct"); |
77 | static_assert(char32_t_value == 8706, "char32_t_value is correct"); |
78 | |