xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/cxx_exprs.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Test this without pch.
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // Test with pch. Use '-ast-dump' to force deserialization of function bodies.
5*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx_exprs.h
6*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // expected-no-diagnostics
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc int integer;
11*f4a2713aSLionel Sambuc double floating;
12*f4a2713aSLionel Sambuc char character;
13*f4a2713aSLionel Sambuc bool boolean;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // CXXStaticCastExpr
16*f4a2713aSLionel Sambuc static_cast_result void_ptr = &integer;
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // CXXDynamicCastExpr
19*f4a2713aSLionel Sambuc Derived *d;
20*f4a2713aSLionel Sambuc dynamic_cast_result derived_ptr = d;
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // CXXReinterpretCastExpr
23*f4a2713aSLionel Sambuc reinterpret_cast_result void_ptr2 = &integer;
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc // CXXConstCastExpr
26*f4a2713aSLionel Sambuc const_cast_result char_ptr = &character;
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // CXXFunctionalCastExpr
29*f4a2713aSLionel Sambuc functional_cast_result *double_ptr = &floating;
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // CXXBoolLiteralExpr
32*f4a2713aSLionel Sambuc bool_literal_result *bool_ptr = &boolean;
33*f4a2713aSLionel Sambuc static_assert(true_value, "true_value is true");
34*f4a2713aSLionel Sambuc static_assert(!false_value, "false_value is false");
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc // CXXNullPtrLiteralExpr
37*f4a2713aSLionel Sambuc cxx_null_ptr_result null_ptr = nullptr;
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc // CXXTypeidExpr
40*f4a2713aSLionel Sambuc typeid_result1 typeid_1 = 0;
41*f4a2713aSLionel Sambuc typeid_result2 typeid_2 = 0;
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc // CharacterLiteral variants
44*f4a2713aSLionel Sambuc static_assert(char_value == 97, "char_value is correct");
45*f4a2713aSLionel Sambuc static_assert(wchar_t_value == 305, "wchar_t_value is correct");
46*f4a2713aSLionel Sambuc static_assert(char16_t_value == 231, "char16_t_value is correct");
47*f4a2713aSLionel Sambuc static_assert(char32_t_value == 8706, "char32_t_value is correct");
48