brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 35db82e Raw
89 lines · c
1// Header for PCH test cxx_exprs.cpp2 3 4// CXXStaticCastExpr5typedef __typeof__(static_cast<void *>(0)) static_cast_result;6 7// CXXDynamicCastExpr8struct Base { Base(int); virtual void f(int x = 492); ~Base(); };9struct Derived : Base { Derived(); void g(); };10Base *base_ptr;11typedef __typeof__(dynamic_cast<Derived *>(base_ptr)) dynamic_cast_result;12 13// CXXReinterpretCastExpr14typedef __typeof__(reinterpret_cast<void *>(0)) reinterpret_cast_result;15 16// CXXConstCastExpr17const char *const_char_ptr_value;18typedef __typeof__(const_cast<char *>(const_char_ptr_value)) const_cast_result;19 20// CXXFunctionalCastExpr21int int_value;22typedef __typeof__(double(int_value)) functional_cast_result;23 24// CXXBoolLiteralExpr25typedef __typeof__(true) bool_literal_result;26const bool true_value = true;27const bool false_value = false;28 29// CXXNullPtrLiteralExpr30typedef __typeof__(nullptr) cxx_null_ptr_result;31 32void foo(Derived *P) {33  // CXXMemberCallExpr34  P->f(12);35}36 37 38// FIXME: This is a hack until <typeinfo> works completely.39namespace std {40  class type_info {};41}42 43// CXXTypeidExpr - Both expr and type forms.44typedef __typeof__(typeid(int))* typeid_result1;45typedef __typeof__(typeid(2))*   typeid_result2;46 47Derived foo();48 49Derived::Derived() : Base(4) {50}51 52void Derived::g() {53  // CXXThisExpr54  f(2);        // Implicit55  this->f(1);  // Explicit56  57  // CXXThrowExpr58  throw;59  throw 42;60  61  // CXXDefaultArgExpr62  f();63  64  const Derived &X = foo();65  66  // FIXME: How do I make a CXXBindReferenceExpr, CXXConstructExpr? 67  68  int A = int(0.5);  // CXXFunctionalCastExpr69  A = int();         // CXXZeroInitValueExpr70  71  Base *b = new Base(4);       // CXXNewExpr72  delete b;                    // CXXDeleteExpr73}74 75 76// FIXME: The comment on CXXTemporaryObjectExpr is broken, this doesn't make77// one.78struct CtorStruct { CtorStruct(int, float); };79 80CtorStruct create_CtorStruct() {81  return CtorStruct(1, 3.14f); // CXXTemporaryObjectExpr82};83 84// CharacterLiteral variants85const char char_value = 'a';86const wchar_t wchar_t_value = L'ı';87const char16_t char16_t_value = u'ç';88const char32_t char32_t_value = U'∂';89