summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/Inputs/namespaces.h27
-rw-r--r--test/PCH/cxx_exprs.cpp4
-rw-r--r--test/PCH/cxx_exprs.h58
-rw-r--r--test/PCH/namespaces.cpp29
4 files changed, 116 insertions, 2 deletions
diff --git a/test/PCH/Inputs/namespaces.h b/test/PCH/Inputs/namespaces.h
index 1bab746..553aadd 100644
--- a/test/PCH/Inputs/namespaces.h
+++ b/test/PCH/Inputs/namespaces.h
@@ -6,8 +6,35 @@ namespace N1 {
namespace N1 {
typedef int t2;
+
+ void used_func();
+
+ struct used_cls { };
}
namespace N2 {
typedef float t1;
+
+ namespace Inner {
+ typedef int t3;
+ };
+}
+
+namespace {
+ void anon() { }
+ class C;
+}
+
+namespace N3 {
+ namespace {
+ class C;
+ }
+}
+
+namespace Alias1 = N2::Inner;
+
+using namespace N2::Inner;
+
+extern "C" {
+ void ext();
}
diff --git a/test/PCH/cxx_exprs.cpp b/test/PCH/cxx_exprs.cpp
index 0f0fe88..ec7041b 100644
--- a/test/PCH/cxx_exprs.cpp
+++ b/test/PCH/cxx_exprs.cpp
@@ -33,3 +33,7 @@ static_assert(!false_value, "false_value is false");
// CXXNullPtrLiteralExpr
cxx_null_ptr_result null_ptr = nullptr;
+
+// CXXTypeidExpr
+typeid_result1 typeid_1 = 0;
+typeid_result2 typeid_2 = 0; \ No newline at end of file
diff --git a/test/PCH/cxx_exprs.h b/test/PCH/cxx_exprs.h
index a871aa2..f647922 100644
--- a/test/PCH/cxx_exprs.h
+++ b/test/PCH/cxx_exprs.h
@@ -1,11 +1,12 @@
// Header for PCH test cxx_exprs.cpp
+
// CXXStaticCastExpr
typedef __typeof__(static_cast<void *>(0)) static_cast_result;
// CXXDynamicCastExpr
-struct Base { virtual void f(); };
-struct Derived : Base { };
+struct Base { Base(int); virtual void f(int x = 492); ~Base(); };
+struct Derived : Base { Derived(); void g(); };
Base *base_ptr;
typedef __typeof__(dynamic_cast<Derived *>(base_ptr)) dynamic_cast_result;
@@ -27,3 +28,56 @@ const bool false_value = false;
// CXXNullPtrLiteralExpr
typedef __typeof__(nullptr) cxx_null_ptr_result;
+
+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
+
+ new Base(4); // CXXNewExpr
+
+}
+
+
+// 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
+};
+
diff --git a/test/PCH/namespaces.cpp b/test/PCH/namespaces.cpp
index eef9e06..532d627 100644
--- a/test/PCH/namespaces.cpp
+++ b/test/PCH/namespaces.cpp
@@ -8,7 +8,36 @@
int int_val;
N1::t1 *ip1 = &int_val;
N1::t2 *ip2 = &int_val;
+N2::Inner::t3 *ip3 = &int_val;
float float_val;
namespace N2 { }
N2::t1 *fp1 = &float_val;
+
+Alias1::t3 *ip4 = &int_val;
+t3 *ip5 = &int_val;
+
+void(*funp1)() = anon;
+
+namespace {
+ class C;
+}
+C* cp1;
+
+namespace N3 {
+ namespace {
+ class C;
+ }
+}
+
+N3::C *cp2;
+
+void(*funp2)() = ext;
+
+using N1::used_func;
+void (*pused)() = used_func;
+
+// FIXME: Disabled until CXXRecord serialization is re-added.
+// using N1::used_cls;
+// used_cls s1;
+// used_cls* ps1 = &s1;
OpenPOWER on IntegriCloud