freebsd-nq/test/PCH/cxx_exprs.h

84 lines
1.9 KiB
C
Raw Normal View History

2010-01-23 11:10:26 +00:00
// Header for PCH test cxx_exprs.cpp
2010-05-27 15:17:06 +00:00
2010-01-23 11:10:26 +00:00
// CXXStaticCastExpr
2010-02-16 09:31:36 +00:00
typedef __typeof__(static_cast<void *>(0)) static_cast_result;
2010-01-23 11:10:26 +00:00
// CXXDynamicCastExpr
2010-05-27 15:17:06 +00:00
struct Base { Base(int); virtual void f(int x = 492); ~Base(); };
struct Derived : Base { Derived(); void g(); };
2010-01-23 11:10:26 +00:00
Base *base_ptr;
2010-02-16 09:31:36 +00:00
typedef __typeof__(dynamic_cast<Derived *>(base_ptr)) dynamic_cast_result;
2010-01-23 11:10:26 +00:00
// CXXReinterpretCastExpr
2010-02-16 09:31:36 +00:00
typedef __typeof__(reinterpret_cast<void *>(0)) reinterpret_cast_result;
2010-01-23 11:10:26 +00:00
// CXXConstCastExpr
const char *const_char_ptr_value;
2010-02-16 09:31:36 +00:00
typedef __typeof__(const_cast<char *>(const_char_ptr_value)) const_cast_result;
2010-01-23 11:10:26 +00:00
// CXXFunctionalCastExpr
int int_value;
2010-02-16 09:31:36 +00:00
typedef __typeof__(double(int_value)) functional_cast_result;
// CXXBoolLiteralExpr
typedef __typeof__(true) bool_literal_result;
const bool true_value = true;
const bool false_value = false;
// CXXNullPtrLiteralExpr
typedef __typeof__(nullptr) cxx_null_ptr_result;
2010-05-27 15:17:06 +00:00
void foo(Derived *P) {
// CXXMemberCallExpr
P->f(12);
}
// FIXME: This is a hack until <typeinfo> works completely.
namespace std {
class type_info {};
}
// CXXTypeidExpr - Both expr and type forms.
typedef __typeof__(typeid(int))* typeid_result1;
typedef __typeof__(typeid(2))* typeid_result2;
Derived foo();
Derived::Derived() : Base(4) {
}
void Derived::g() {
// CXXThisExpr
f(2); // Implicit
this->f(1); // Explicit
// CXXThrowExpr
throw;
throw 42;
// CXXDefaultArgExpr
f();
const Derived &X = foo();
// FIXME: How do I make a CXXBindReferenceExpr, CXXConstructExpr?
int A = int(0.5); // CXXFunctionalCastExpr
A = int(); // CXXZeroInitValueExpr
2010-07-13 17:21:42 +00:00
Base *b = new Base(4); // CXXNewExpr
delete b; // CXXDeleteExpr
2010-05-27 15:17:06 +00:00
}
// FIXME: The comment on CXXTemporaryObjectExpr is broken, this doesn't make
// one.
struct CtorStruct { CtorStruct(int, float); };
CtorStruct create_CtorStruct() {
return CtorStruct(1, 3.14f); // CXXTemporaryObjectExpr
};