summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/cxx-alias-decl.cpp20
-rw-r--r--test/PCH/cxx-alias-decl.h11
-rw-r--r--test/PCH/cxx-for-range.cpp6
-rw-r--r--test/PCH/cxx-member-init.cpp22
-rw-r--r--test/PCH/cxx-reference.cpp6
-rw-r--r--test/PCH/cxx-static_assert.cpp15
-rw-r--r--test/PCH/cxx-static_assert.h9
-rw-r--r--test/PCH/cxx0x-default-delete.cpp23
-rw-r--r--test/PCH/cxx0x-delegating-ctors.cpp20
-rw-r--r--test/PCH/modified-header-error.c11
-rw-r--r--test/PCH/objc_methods.h2
-rw-r--r--test/PCH/objc_methods.m2
-rw-r--r--test/PCH/objcxx-ivar-class.mm2
13 files changed, 128 insertions, 21 deletions
diff --git a/test/PCH/cxx-alias-decl.cpp b/test/PCH/cxx-alias-decl.cpp
new file mode 100644
index 0000000..e30311c
--- /dev/null
+++ b/test/PCH/cxx-alias-decl.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-alias-decl.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-alias-decl.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+template struct T<S>;
+C<A>::A<char> a;
+
+using T1 = decltype(a);
+using T1 = D<int, char>;
+
+using T2 = B<A>;
+using T2 = S;
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/test/PCH/cxx-alias-decl.h b/test/PCH/cxx-alias-decl.h
new file mode 100644
index 0000000..26bc716
--- /dev/null
+++ b/test/PCH/cxx-alias-decl.h
@@ -0,0 +1,11 @@
+// Header for PCH test cxx-alias-decl.cpp
+
+struct S {};
+template<typename U> struct T {
+ template<typename V> using A = T<V>;
+};
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/test/PCH/cxx-for-range.cpp b/test/PCH/cxx-for-range.cpp
index 5854917..46e217c 100644
--- a/test/PCH/cxx-for-range.cpp
+++ b/test/PCH/cxx-for-range.cpp
@@ -1,9 +1,9 @@
// Test this without pch.
-// RUN: %clang_cc1 -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s
// Test with pch.
-// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-for-range.h
-// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-for-range.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
void h() {
f();
diff --git a/test/PCH/cxx-member-init.cpp b/test/PCH/cxx-member-init.cpp
new file mode 100644
index 0000000..70392a2
--- /dev/null
+++ b/test/PCH/cxx-member-init.cpp
@@ -0,0 +1,22 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -DSOURCE -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+#ifdef HEADER
+int n;
+struct S {
+ int *p = &m;
+ int &m = n;
+ S *that = this;
+};
+#endif
+
+#ifdef SOURCE
+S s;
+#elif HEADER
+#undef HEADER
+#define SOURCE
+#endif
diff --git a/test/PCH/cxx-reference.cpp b/test/PCH/cxx-reference.cpp
index 90d00d7..2dfbcdc 100644
--- a/test/PCH/cxx-reference.cpp
+++ b/test/PCH/cxx-reference.cpp
@@ -1,6 +1,6 @@
// Test this without pch.
-// RUN: %clang_cc1 -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
// Test with pch.
-// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-reference.h
-// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-reference.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp
index 3440921..464da40 100644
--- a/test/PCH/cxx-static_assert.cpp
+++ b/test/PCH/cxx-static_assert.cpp
@@ -1,11 +1,20 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-static_assert.h -verify -std=c++0x %s
+// RUN: %clang_cc1 -include %s -verify -std=c++0x %s
// Test with pch.
-// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %S/cxx-static_assert.h
+// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %s
// RUN: %clang_cc1 -include-pch %t -verify -std=c++0x %s
-// expected-error {{static_assert failed "N is not 2!"}}
+#ifndef HEADER
+#define HEADER
+
+template<int N> struct T {
+ static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}}
+};
+
+#else
T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
T<2> t2;
+
+#endif
diff --git a/test/PCH/cxx-static_assert.h b/test/PCH/cxx-static_assert.h
deleted file mode 100644
index ba41ab8..0000000
--- a/test/PCH/cxx-static_assert.h
+++ /dev/null
@@ -1,9 +0,0 @@
-// Header for PCH test cxx-static_assert.cpp
-
-
-
-
-
-template<int N> struct T {
- static_assert(N == 2, "N is not 2!");
-};
diff --git a/test/PCH/cxx0x-default-delete.cpp b/test/PCH/cxx0x-default-delete.cpp
new file mode 100644
index 0000000..753ac47
--- /dev/null
+++ b/test/PCH/cxx0x-default-delete.cpp
@@ -0,0 +1,23 @@
+// Without PCH
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include %s %s
+// With PCH
+// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include-pch %t %s
+
+#ifndef PASS1
+#define PASS1
+
+struct foo {
+ foo() = default;
+ void bar() = delete; // expected-note{{deleted here}}
+};
+
+#else
+
+foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
+foo f;
+void fn() {
+ f.bar(); // expected-error{{deleted function}}
+}
+
+#endif
diff --git a/test/PCH/cxx0x-delegating-ctors.cpp b/test/PCH/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..15311f8
--- /dev/null
+++ b/test/PCH/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -std=c++0x -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -verify %s
+
+#ifndef PASS1
+#define PASS1
+struct foo {
+ foo(int) : foo() { } // expected-note{{it delegates to}}
+ foo();
+ foo(bool) : foo('c') { } // expected-note{{it delegates to}}
+ foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+};
+#else
+foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+#endif
diff --git a/test/PCH/modified-header-error.c b/test/PCH/modified-header-error.c
new file mode 100644
index 0000000..6335fb1
--- /dev/null
+++ b/test/PCH/modified-header-error.c
@@ -0,0 +1,11 @@
+// RUN: mkdir -p %t.dir
+// RUN: echo '#include "header2.h"' > %t.dir/header1.h
+// RUN: echo > %t.dir/header2.h
+// RUN: cp %s %t.dir/t.c
+// RUN: %clang_cc1 -x c-header %t.dir/header1.h -emit-pch -o %t.pch
+// RUN: echo >> %t.dir/header2.h
+// RUN: %clang_cc1 %t.dir/t.c -include-pch %t.pch -fsyntax-only 2>&1 | FileCheck %s
+
+#include "header2.h"
+
+// CHECK: fatal error: file {{.*}} has been modified since the precompiled header was built
diff --git a/test/PCH/objc_methods.h b/test/PCH/objc_methods.h
index 4c6b1e1..bd77535 100644
--- a/test/PCH/objc_methods.h
+++ b/test/PCH/objc_methods.h
@@ -2,7 +2,7 @@
@interface TestPCH
+ alloc;
-- (void)instMethod;
+- (id)init;
@end
@class TestForwardClassDecl;
diff --git a/test/PCH/objc_methods.m b/test/PCH/objc_methods.m
index e90a463..3311813 100644
--- a/test/PCH/objc_methods.m
+++ b/test/PCH/objc_methods.m
@@ -12,5 +12,5 @@ void func() {
// AliasForTestPCH *zz;
xx = [TestPCH alloc];
- [xx instMethod];
+ [xx init];
}
diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm
index 89d3e08..8214957 100644
--- a/test/PCH/objcxx-ivar-class.mm
+++ b/test/PCH/objcxx-ivar-class.mm
@@ -6,7 +6,7 @@
// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
// CHECK: [C position]
-// CHECK: call void @_ZN1SC1ERKS_
+// CHECK: call {{.*}} @_ZN1SC1ERKS_
// CHECK: [C setPosition:]
// CHECK: call %struct.S* @_ZN1SaSERKS_
OpenPOWER on IntegriCloud