summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/Inputs/chain-cxx1.h19
-rw-r--r--test/PCH/Inputs/chain-cxx2.h32
-rw-r--r--test/PCH/Inputs/chain-decls1.h11
-rw-r--r--test/PCH/Inputs/chain-decls2.h12
-rw-r--r--test/PCH/Inputs/chain-ext_vector1.h3
-rw-r--r--test/PCH/Inputs/chain-ext_vector2.h3
-rw-r--r--test/PCH/Inputs/chain-external-defs1.h13
-rw-r--r--test/PCH/Inputs/chain-external-defs2.h11
-rw-r--r--test/PCH/Inputs/chain-macro-override1.h4
-rw-r--r--test/PCH/Inputs/chain-macro-override2.h4
-rw-r--r--test/PCH/Inputs/chain-macro1.h1
-rw-r--r--test/PCH/Inputs/chain-macro2.h1
-rw-r--r--test/PCH/Inputs/chain-selectors1.h12
-rw-r--r--test/PCH/Inputs/chain-selectors2.h11
-rw-r--r--test/PCH/Inputs/chain-trivial1.h0
-rw-r--r--test/PCH/Inputs/chain-trivial2.h0
-rw-r--r--test/PCH/Inputs/preamble.h1
-rw-r--r--test/PCH/chain-cxx.cpp28
-rw-r--r--test/PCH/chain-decls.c27
-rw-r--r--test/PCH/chain-ext_vector.c11
-rw-r--r--test/PCH/chain-external-defs.c54
-rw-r--r--test/PCH/chain-macro-override.c13
-rw-r--r--test/PCH/chain-macro.c9
-rw-r--r--test/PCH/chain-predecl.h3
-rw-r--r--test/PCH/chain-predecl.m16
-rw-r--r--test/PCH/chain-selectors.m24
-rw-r--r--test/PCH/chain-trivial.c4
-rw-r--r--test/PCH/cxx-offsetof-base.cpp2
-rw-r--r--test/PCH/cxx-offsetof-base.h5
-rw-r--r--test/PCH/cxx-required-decls.cpp10
-rw-r--r--test/PCH/cxx-required-decls.h12
-rw-r--r--test/PCH/cxx-static_assert.cpp11
-rw-r--r--test/PCH/cxx-static_assert.h9
-rw-r--r--test/PCH/cxx-templates.cpp14
-rw-r--r--test/PCH/cxx-templates.h37
-rw-r--r--test/PCH/cxx-traits.cpp8
-rw-r--r--test/PCH/cxx-traits.h11
-rw-r--r--test/PCH/cxx-typeid.cpp9
-rw-r--r--test/PCH/cxx-typeid.h3
-rw-r--r--test/PCH/namespaces.cpp7
-rw-r--r--test/PCH/objcxx-ivar-class.h15
-rw-r--r--test/PCH/objcxx-ivar-class.mm15
-rw-r--r--test/PCH/pragma-weak.c10
-rw-r--r--test/PCH/pragma-weak.h10
-rw-r--r--test/PCH/preamble.c21
-rw-r--r--test/PCH/pth.c7
-rw-r--r--test/PCH/pth.h12
-rw-r--r--test/PCH/reinclude.cpp8
-rw-r--r--test/PCH/reinclude1.h4
-rw-r--r--test/PCH/reinclude2.h1
-rw-r--r--test/PCH/selector-warning.h24
-rw-r--r--test/PCH/selector-warning.m19
52 files changed, 604 insertions, 7 deletions
diff --git a/test/PCH/Inputs/chain-cxx1.h b/test/PCH/Inputs/chain-cxx1.h
new file mode 100644
index 0000000..7ea3ffb
--- /dev/null
+++ b/test/PCH/Inputs/chain-cxx1.h
@@ -0,0 +1,19 @@
+// Primary header for C++ chained PCH test
+
+void f();
+
+// Name not appearing in dependent
+void pf();
+
+namespace ns {
+ void g();
+
+ void pg();
+}
+
+template <typename T>
+struct S { typedef int G; };
+
+// Partially specialize
+template <typename T>
+struct S<T *> { typedef int H; };
diff --git a/test/PCH/Inputs/chain-cxx2.h b/test/PCH/Inputs/chain-cxx2.h
new file mode 100644
index 0000000..adc10fd
--- /dev/null
+++ b/test/PCH/Inputs/chain-cxx2.h
@@ -0,0 +1,32 @@
+// Dependent header for C++ chained PCH test
+
+// Overload function from primary
+void f(int);
+
+// Add function with different name
+void f2();
+
+// Reopen namespace
+namespace ns {
+ // Overload function from primary
+ void g(int);
+
+ // Add different name
+ void g2();
+}
+
+// Specialize template from primary
+template <>
+struct S<int> { typedef int I; };
+
+// Partially specialize
+template <typename T>
+struct S<T &> { typedef int J; };
+
+// Specialize previous partial specialization
+template <>
+struct S<int *> { typedef int K; };
+
+// Specialize the partial specialization from this file
+template <>
+struct S<int &> { typedef int L; };
diff --git a/test/PCH/Inputs/chain-decls1.h b/test/PCH/Inputs/chain-decls1.h
new file mode 100644
index 0000000..9de4461
--- /dev/null
+++ b/test/PCH/Inputs/chain-decls1.h
@@ -0,0 +1,11 @@
+void f();
+
+struct one {};
+void two();
+
+void many(int i);
+struct many;
+void many(int j);
+struct many;
+
+void noret();
diff --git a/test/PCH/Inputs/chain-decls2.h b/test/PCH/Inputs/chain-decls2.h
new file mode 100644
index 0000000..b8b7d04
--- /dev/null
+++ b/test/PCH/Inputs/chain-decls2.h
@@ -0,0 +1,12 @@
+void g();
+
+struct two {};
+void one();
+struct three {}; // for verification
+
+void many(int k);
+struct many;
+void many(int l);
+struct many {};
+
+void noret() __attribute__((noreturn));
diff --git a/test/PCH/Inputs/chain-ext_vector1.h b/test/PCH/Inputs/chain-ext_vector1.h
new file mode 100644
index 0000000..5109336
--- /dev/null
+++ b/test/PCH/Inputs/chain-ext_vector1.h
@@ -0,0 +1,3 @@
+// First header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(2))) float float2;
diff --git a/test/PCH/Inputs/chain-ext_vector2.h b/test/PCH/Inputs/chain-ext_vector2.h
new file mode 100644
index 0000000..bdaeccc
--- /dev/null
+++ b/test/PCH/Inputs/chain-ext_vector2.h
@@ -0,0 +1,3 @@
+// Second header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(4))) float float4;
diff --git a/test/PCH/Inputs/chain-external-defs1.h b/test/PCH/Inputs/chain-external-defs1.h
new file mode 100644
index 0000000..36a2653
--- /dev/null
+++ b/test/PCH/Inputs/chain-external-defs1.h
@@ -0,0 +1,13 @@
+// Helper 1 for chain-external-defs.c test
+
+// Tentative definitions
+int x;
+int x2;
+
+// Should not show up
+static int z;
+
+int incomplete_array[];
+int incomplete_array2[];
+
+struct S s;
diff --git a/test/PCH/Inputs/chain-external-defs2.h b/test/PCH/Inputs/chain-external-defs2.h
new file mode 100644
index 0000000..72af92f
--- /dev/null
+++ b/test/PCH/Inputs/chain-external-defs2.h
@@ -0,0 +1,11 @@
+// Helper 2 for chain-external-defs.c test
+
+// Tentative definitions
+int y;
+int y2;
+
+// Should still not show up
+static int z;
+
+int incomplete_array[];
+int incomplete_array3[];
diff --git a/test/PCH/Inputs/chain-macro-override1.h b/test/PCH/Inputs/chain-macro-override1.h
new file mode 100644
index 0000000..4f9321d
--- /dev/null
+++ b/test/PCH/Inputs/chain-macro-override1.h
@@ -0,0 +1,4 @@
+void f() __attribute__((unavailable));
+void g();
+#define g() f()
+#define h() f()
diff --git a/test/PCH/Inputs/chain-macro-override2.h b/test/PCH/Inputs/chain-macro-override2.h
new file mode 100644
index 0000000..f279e2a
--- /dev/null
+++ b/test/PCH/Inputs/chain-macro-override2.h
@@ -0,0 +1,4 @@
+#define f() g()
+#undef g
+#undef h
+#define h() g()
diff --git a/test/PCH/Inputs/chain-macro1.h b/test/PCH/Inputs/chain-macro1.h
new file mode 100644
index 0000000..2e80e47
--- /dev/null
+++ b/test/PCH/Inputs/chain-macro1.h
@@ -0,0 +1 @@
+#define FOOBAR void f();
diff --git a/test/PCH/Inputs/chain-macro2.h b/test/PCH/Inputs/chain-macro2.h
new file mode 100644
index 0000000..e888228
--- /dev/null
+++ b/test/PCH/Inputs/chain-macro2.h
@@ -0,0 +1 @@
+#define BARFOO void g();
diff --git a/test/PCH/Inputs/chain-selectors1.h b/test/PCH/Inputs/chain-selectors1.h
new file mode 100644
index 0000000..37c1c00
--- /dev/null
+++ b/test/PCH/Inputs/chain-selectors1.h
@@ -0,0 +1,12 @@
+@interface X
+ -(void)f;
+ -(void)f2;
+ -(void)g:(int)p;
+ -(void)h:(int)p1 foo:(int)p2;
+@end
+
+void foo1() {
+ // FIXME: Can't verify warnings in headers
+ //(void)@selector(x);
+ (void)@selector(f);
+}
diff --git a/test/PCH/Inputs/chain-selectors2.h b/test/PCH/Inputs/chain-selectors2.h
new file mode 100644
index 0000000..4d6b556
--- /dev/null
+++ b/test/PCH/Inputs/chain-selectors2.h
@@ -0,0 +1,11 @@
+@interface Y
+ -(void)f;
+ -(double)f2;
+ -(void)e;
+@end
+
+void foo2() {
+ // FIXME: Can't verify warnings in headers
+ //(void)@selector(y);
+ //(void)@selector(e);
+}
diff --git a/test/PCH/Inputs/chain-trivial1.h b/test/PCH/Inputs/chain-trivial1.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/PCH/Inputs/chain-trivial1.h
diff --git a/test/PCH/Inputs/chain-trivial2.h b/test/PCH/Inputs/chain-trivial2.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/PCH/Inputs/chain-trivial2.h
diff --git a/test/PCH/Inputs/preamble.h b/test/PCH/Inputs/preamble.h
new file mode 100644
index 0000000..aee330a
--- /dev/null
+++ b/test/PCH/Inputs/preamble.h
@@ -0,0 +1 @@
+int f(int);
diff --git a/test/PCH/chain-cxx.cpp b/test/PCH/chain-cxx.cpp
new file mode 100644
index 0000000..3e46214
--- /dev/null
+++ b/test/PCH/chain-cxx.cpp
@@ -0,0 +1,28 @@
+// Test C++ chained PCH functionality
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %S/Inputs/chain-cxx1.h -include %S/Inputs/chain-cxx2.h %s
+
+// With PCH
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t1 %S/Inputs/chain-cxx1.h
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t2 %S/Inputs/chain-cxx2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
+
+void test() {
+ f();
+ f(1);
+ pf();
+ f2();
+
+ ns::g();
+ ns::g(1);
+ ns::pg();
+ ns::g2();
+
+ typedef S<double>::G T1;
+ typedef S<double *>::H T2;
+ typedef S<int>::I T3;
+ typedef S<double &>::J T4;
+ typedef S<int *>::K T5;
+ typedef S<int &>::L T6;
+}
diff --git a/test/PCH/chain-decls.c b/test/PCH/chain-decls.c
new file mode 100644
index 0000000..b3daa4a
--- /dev/null
+++ b/test/PCH/chain-decls.c
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-decls1.h -include %S/Inputs/chain-decls2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-decls1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: void f();
+// CHECK: void g();
+
+int h() {
+ f();
+ g();
+
+ struct one x;
+ one();
+ struct two y;
+ two();
+ struct three z;
+
+ many(0);
+ struct many m;
+
+ noret();
+}
diff --git a/test/PCH/chain-ext_vector.c b/test/PCH/chain-ext_vector.c
new file mode 100644
index 0000000..2635070
--- /dev/null
+++ b/test/PCH/chain-ext_vector.c
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-ext_vector1.h -include %S/Inputs/chain-ext_vector2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-ext_vector1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+
+int test(float4 f4) {
+ return f4.xy; // expected-error{{float2}}
+}
diff --git a/test/PCH/chain-external-defs.c b/test/PCH/chain-external-defs.c
new file mode 100644
index 0000000..dd92d8e
--- /dev/null
+++ b/test/PCH/chain-external-defs.c
@@ -0,0 +1,54 @@
+// Test with pch.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t1.pch %S/Inputs/chain-external-defs1.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t2.pch %S/Inputs/chain-external-defs2.h -include-pch %t1.pch -chained-pch
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t2.pch -emit-llvm -o %t %s
+// RUN: echo FINI >> %t
+// RUN: FileCheck -input-file=%t -check-prefix=Z %s
+// RUN: FileCheck -input-file=%t -check-prefix=XA %s
+// RUN: FileCheck -input-file=%t -check-prefix=YA %s
+// RUN: FileCheck -input-file=%t -check-prefix=XB %s
+// RUN: FileCheck -input-file=%t -check-prefix=YB %s
+// RUN: FileCheck -input-file=%t -check-prefix=AA %s
+// RUN: FileCheck -input-file=%t -check-prefix=AB %s
+// RUN: FileCheck -input-file=%t -check-prefix=AC %s
+// RUN: FileCheck -input-file=%t -check-prefix=S %s
+
+// Z-NOT: @z
+
+// XA: @x = common global i32 0
+// XA-NOT: @x = common global i32 0
+
+// YA: @y = common global i32 0
+// YA-NOT: @y = common global i32 0
+
+// XB: @x2 = global i32 19
+// XB-NOT: @x2 = global i32 19
+int x2 = 19;
+// YB: @y2 = global i32 18
+// YB-NOT: @y2 = global i32 18
+int y2 = 18;
+
+// AA: @incomplete_array = common global [1 x i32]
+// AA-NOT: @incomplete_array = common global [1 x i32]
+// AB: @incomplete_array2 = common global [17 x i32]
+// AB-NOT: @incomplete_array2 = common global [17 x i32]
+int incomplete_array2[17];
+// AC: @incomplete_array3 = common global [1 x i32]
+// AC-NOT: @incomplete_array3 = common global [1 x i32]
+int incomplete_array3[];
+
+// S: @s = common global %struct.S
+// S-NOT: @s = common global %struct.S
+struct S {
+ int x, y;
+};
+
+// Z: FINI
+// XA: FINI
+// YA: FINI
+// XB: FINI
+// YB: FINI
+// AA: FINI
+// AB: FINI
+// AC: FINI
+// S: FINI
diff --git a/test/PCH/chain-macro-override.c b/test/PCH/chain-macro-override.c
new file mode 100644
index 0000000..14478af
--- /dev/null
+++ b/test/PCH/chain-macro-override.c
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-macro-override1.h -include %S/Inputs/chain-macro-override2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+
+void foo() {
+ f();
+ g();
+ h();
+}
diff --git a/test/PCH/chain-macro.c b/test/PCH/chain-macro.c
new file mode 100644
index 0000000..b4dcdfe
--- /dev/null
+++ b/test/PCH/chain-macro.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: void f();
+FOOBAR
+// CHECK: void g();
+BARFOO
diff --git a/test/PCH/chain-predecl.h b/test/PCH/chain-predecl.h
new file mode 100644
index 0000000..bd332ff
--- /dev/null
+++ b/test/PCH/chain-predecl.h
@@ -0,0 +1,3 @@
+// First header for chain-predecl.m
+@class Foo;
+@protocol Pro;
diff --git a/test/PCH/chain-predecl.m b/test/PCH/chain-predecl.m
new file mode 100644
index 0000000..2b0444e
--- /dev/null
+++ b/test/PCH/chain-predecl.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/chain-predecl.h -x objective-c
+// RUN: %clang_cc1 -emit-pch -o %t2 %s -x objective-c -include-pch %t1 -chained-pch
+
+// Test predeclarations across chained PCH.
+@interface Foo
+-(void)bar;
+@end
+@interface Boom
+-(void)bar;
+@end
+@protocol Pro
+-(void)baz;
+@end
+@protocol Kaboom
+-(void)baz;
+@end
diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m
new file mode 100644
index 0000000..60db3f9
--- /dev/null
+++ b/test/PCH/chain-selectors.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
+
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2
+
+@implementation X
+-(void)f {}
+-(void)f2 {}
+-(void)g: (int)p {}
+-(void)h: (int)p1 foo: (int)p2 {}
+@end
+
+void bar() {
+ id a = 0;
+ [a nothing]; // expected-warning {{method '-nothing' not found}}
+ [a f];
+ // FIXME: Can't verify notes in headers
+ //[a f2];
+
+ (void)@selector(x); // expected-warning {{unimplemented selector}}
+ (void)@selector(y); // expected-warning {{unimplemented selector}}
+ (void)@selector(e); // expected-warning {{unimplemented selector}}
+}
diff --git a/test/PCH/chain-trivial.c b/test/PCH/chain-trivial.c
new file mode 100644
index 0000000..c78b0e4
--- /dev/null
+++ b/test/PCH/chain-trivial.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t1 %S/Inputs/chain-trivial1.h
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 -chained-pch %S/Inputs/chain-trivial2.h
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-print -include-pch %t2 %s | FileCheck %s
+// CHECK: struct __va_list_tag {
diff --git a/test/PCH/cxx-offsetof-base.cpp b/test/PCH/cxx-offsetof-base.cpp
new file mode 100644
index 0000000..18265de
--- /dev/null
+++ b/test/PCH/cxx-offsetof-base.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-offsetof-base.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
diff --git a/test/PCH/cxx-offsetof-base.h b/test/PCH/cxx-offsetof-base.h
new file mode 100644
index 0000000..7c78101
--- /dev/null
+++ b/test/PCH/cxx-offsetof-base.h
@@ -0,0 +1,5 @@
+// Header for PCH test cxx-offsetof-base.cpp
+
+struct Base { int x; };
+struct Derived : Base { int y; };
+int o = __builtin_offsetof(Derived, x);
diff --git a/test/PCH/cxx-required-decls.cpp b/test/PCH/cxx-required-decls.cpp
new file mode 100644
index 0000000..8c4b11c
--- /dev/null
+++ b/test/PCH/cxx-required-decls.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-required-decls.h %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-required-decls.h
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZL5globS = internal global %struct.S zeroinitializer
+// CHECK: @_ZL3bar = internal global i32 0, align 4
+// CHECK: @glob_var = global i32 0
diff --git a/test/PCH/cxx-required-decls.h b/test/PCH/cxx-required-decls.h
new file mode 100644
index 0000000..099d2da
--- /dev/null
+++ b/test/PCH/cxx-required-decls.h
@@ -0,0 +1,12 @@
+// Header for PCH test cxx-required-decls.cpp
+
+struct S {
+ S();
+};
+
+static S globS;
+
+extern int ext_foo;
+static int bar = ++ext_foo;
+
+int glob_var;
diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp
new file mode 100644
index 0000000..3440921
--- /dev/null
+++ b/test/PCH/cxx-static_assert.cpp
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-static_assert.h -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 -include-pch %t -verify -std=c++0x %s
+
+// expected-error {{static_assert failed "N is not 2!"}}
+
+T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
+T<2> t2;
diff --git a/test/PCH/cxx-static_assert.h b/test/PCH/cxx-static_assert.h
new file mode 100644
index 0000000..ba41ab8
--- /dev/null
+++ b/test/PCH/cxx-static_assert.h
@@ -0,0 +1,9 @@
+// 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/cxx-templates.cpp b/test/PCH/cxx-templates.cpp
index f127427..a862ea5 100644
--- a/test/PCH/cxx-templates.cpp
+++ b/test/PCH/cxx-templates.cpp
@@ -1,9 +1,14 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-templates.h -verify %s -ast-dump
+// RUN: %clang_cc1 -include %S/cxx-templates.h -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s
// Test with pch.
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-templates.h
-// RUN: %clang_cc1 -include-pch %t -verify %s -ast-dump
+// RUN: %clang_cc1 -include-pch %t -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define weak_odr void @_ZN2S4IiE1mEv
+// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv
struct A {
typedef int type;
@@ -22,4 +27,9 @@ void test() {
Dep<A>::Ty ty;
Dep<A> a;
a.f();
+
+ S3<int> s3;
+ s3.m();
}
+
+template struct S4<int>;
diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h
index 3968536..978d768 100644
--- a/test/PCH/cxx-templates.h
+++ b/test/PCH/cxx-templates.h
@@ -88,7 +88,8 @@ template<unsigned N>
bool isInt(int x);
template<> bool isInt<8>(int x) {
- return true;
+ try { ++x; } catch(...) { --x; }
+ return true;
}
template<typename _CharT>
@@ -100,3 +101,37 @@ class basic_streambuf
friend int __copy_streambufs_eof<>(int);
};
+// PR 7660
+template<typename T> struct S_PR7660 { void g(void (*)(T)); };
+ template<> void S_PR7660<int>::g(void(*)(int)) {}
+
+// PR 7670
+template<typename> class C_PR7670;
+template<> class C_PR7670<int>;
+template<> class C_PR7670<int>;
+
+template <bool B>
+struct S2 {
+ static bool V;
+};
+
+extern template class S2<true>;
+
+template <typename T>
+struct S3 {
+ void m();
+};
+
+template <typename T>
+inline void S3<T>::m() { }
+
+template <typename T>
+struct S4 {
+ void m() { }
+};
+extern template struct S4<int>;
+
+void S4ImplicitInst() {
+ S4<int> s;
+ s.m();
+}
diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp
new file mode 100644
index 0000000..69c6475
--- /dev/null
+++ b/test/PCH/cxx-traits.cpp
@@ -0,0 +1,8 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-traits.h -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-traits.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+bool _Is_pod_comparator = __is_pod<int>::__value;
+bool _Is_empty_check = __is_empty<int>::__value;
diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h
new file mode 100644
index 0000000..62722ab
--- /dev/null
+++ b/test/PCH/cxx-traits.h
@@ -0,0 +1,11 @@
+// Header for PCH test cxx-traits.cpp
+
+template<typename _Tp>
+struct __is_pod {
+ enum { __value };
+};
+
+template<typename _Tp>
+struct __is_empty {
+ enum { __value };
+};
diff --git a/test/PCH/cxx-typeid.cpp b/test/PCH/cxx-typeid.cpp
new file mode 100644
index 0000000..41dd544
--- /dev/null
+++ b/test/PCH/cxx-typeid.cpp
@@ -0,0 +1,9 @@
+// Test this without pch.
+// RUN: %clang -include %S/cxx-typeid.h -fsyntax-only -Xclang -verify %s
+
+// RUN: %clang -ccc-pch-is-pch -x c++-header -o %t.gch %S/cxx-typeid.h
+// RUN: %clang -ccc-pch-is-pch -include %t -fsyntax-only -Xclang -verify %s
+
+void f() {
+ (void)typeid(int);
+}
diff --git a/test/PCH/cxx-typeid.h b/test/PCH/cxx-typeid.h
new file mode 100644
index 0000000..aa3b16a
--- /dev/null
+++ b/test/PCH/cxx-typeid.h
@@ -0,0 +1,3 @@
+// Header for PCH test cxx-typeid.cpp
+
+#include <typeinfo>
diff --git a/test/PCH/namespaces.cpp b/test/PCH/namespaces.cpp
index 532d627..b8a22e5 100644
--- a/test/PCH/namespaces.cpp
+++ b/test/PCH/namespaces.cpp
@@ -37,7 +37,6 @@ 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;
+using N1::used_cls;
+used_cls s1;
+used_cls* ps1 = &s1;
diff --git a/test/PCH/objcxx-ivar-class.h b/test/PCH/objcxx-ivar-class.h
new file mode 100644
index 0000000..50ebda7
--- /dev/null
+++ b/test/PCH/objcxx-ivar-class.h
@@ -0,0 +1,15 @@
+struct S {
+ S();
+ S(const S&);
+ S& operator= (const S&);
+};
+
+@interface C {
+ S position;
+}
+@property(assign, nonatomic) S position;
+@end
+
+@implementation C
+ @synthesize position;
+@end
diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm
new file mode 100644
index 0000000..89d3e08
--- /dev/null
+++ b/test/PCH/objcxx-ivar-class.mm
@@ -0,0 +1,15 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c++-header -emit-pch -o %t %S/objcxx-ivar-class.h
+// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: [C position]
+// CHECK: call void @_ZN1SC1ERKS_
+
+// CHECK: [C setPosition:]
+// CHECK: call %struct.S* @_ZN1SaSERKS_
+
+// CHECK: [C .cxx_destruct]
+// CHECK: [C .cxx_construct]
diff --git a/test/PCH/pragma-weak.c b/test/PCH/pragma-weak.c
new file mode 100644
index 0000000..18b45c8
--- /dev/null
+++ b/test/PCH/pragma-weak.c
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/pragma-weak.h %s -verify -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c-header -emit-pch -o %t %S/pragma-weak.h
+// RUN: %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s
+
+// CHECK: @weakvar = weak global i32 0
+int weakvar;
+// expected-warning {{weak identifier 'undeclaredvar' never declared}}
diff --git a/test/PCH/pragma-weak.h b/test/PCH/pragma-weak.h
new file mode 100644
index 0000000..42ecd50
--- /dev/null
+++ b/test/PCH/pragma-weak.h
@@ -0,0 +1,10 @@
+// Header for PCH test pragma-weak.c
+
+#pragma weak weakvar
+
+
+
+
+
+
+#pragma weak undeclaredvar
diff --git a/test/PCH/preamble.c b/test/PCH/preamble.c
new file mode 100644
index 0000000..bdc0aea
--- /dev/null
+++ b/test/PCH/preamble.c
@@ -0,0 +1,21 @@
+// Check that using the preamble option actually skips the preamble.
+
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/preamble.h
+// RUN: %clang_cc1 -include-pch %t -preamble-bytes=278,1 -DFOO=f -verify %s
+
+float f(int); // Not an error, because we skip this via the preamble!
+
+
+
+
+
+
+
+
+
+
+
+
+int g(int x) {
+ return FOO(x);
+}
diff --git a/test/PCH/pth.c b/test/PCH/pth.c
new file mode 100644
index 0000000..1262f8a
--- /dev/null
+++ b/test/PCH/pth.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t %S/pth.h
+// RUN: %clang_cc1 -triple i386-unknown-unknown -include-pth %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+#error This is the only diagnostic
+
+// CHECK: This is the only diagnostic
+// CHECK: 1 error generated. \ No newline at end of file
diff --git a/test/PCH/pth.h b/test/PCH/pth.h
new file mode 100644
index 0000000..9ae7021
--- /dev/null
+++ b/test/PCH/pth.h
@@ -0,0 +1,12 @@
+// This case came up when using PTH with Boost (<rdar://problem/8227989>).
+
+# ifndef R8227989_PREPROCESSOR_CONFIG_CONFIG_HPP
+# ifndef R8227989_PP_CONFIG_FLAGS
+# endif
+#
+# ifndef R8227989_PP_CONFIG_ERRORS
+# ifdef NDEBUG
+# endif
+# endif
+# endif
+
diff --git a/test/PCH/reinclude.cpp b/test/PCH/reinclude.cpp
new file mode 100644
index 0000000..6ab1002
--- /dev/null
+++ b/test/PCH/reinclude.cpp
@@ -0,0 +1,8 @@
+// Test without PCH
+// RUN: %clang_cc1 %s -include %S/reinclude1.h -include %S/reinclude2.h -fsyntax-only -verify
+
+// RUN: %clang_cc1 -x c++-header %S/reinclude1.h -emit-pch -o %t1
+// RUN: %clang_cc1 -x c++-header %S/reinclude2.h -include-pch %t1 -emit-pch -o %t2
+// RUN: %clang_cc1 %s -include-pch %t2 -fsyntax-only -verify
+
+int q2 = A::y;
diff --git a/test/PCH/reinclude1.h b/test/PCH/reinclude1.h
new file mode 100644
index 0000000..4c8ccae
--- /dev/null
+++ b/test/PCH/reinclude1.h
@@ -0,0 +1,4 @@
+namespace A {
+ int x;
+ int y;
+}
diff --git a/test/PCH/reinclude2.h b/test/PCH/reinclude2.h
new file mode 100644
index 0000000..2aa6d31
--- /dev/null
+++ b/test/PCH/reinclude2.h
@@ -0,0 +1 @@
+int q1 = A::x;
diff --git a/test/PCH/selector-warning.h b/test/PCH/selector-warning.h
new file mode 100644
index 0000000..bd41929
--- /dev/null
+++ b/test/PCH/selector-warning.h
@@ -0,0 +1,24 @@
+typedef struct objc_selector *SEL;
+
+@interface Foo
+- (void) NotOK;
+@end
+
+@implementation Foo
+- (void) foo
+{
+ SEL a = @selector(b1ar);
+ a = @selector(b1ar);
+ a = @selector(bar);
+ a = @selector(ok); // expected-warning {{unimplemented selector 'ok'}}
+ a = @selector(ok);
+ a = @selector(NotOK); // expected-warning {{unimplemented selector 'NotOK'}}
+ a = @selector(NotOK);
+
+ a = @selector(clNotOk); // expected-warning {{unimplemented selector 'clNotOk'}}
+
+ a = @selector (cl1);
+ a = @selector (cl2);
+ a = @selector (instNotOk); // expected-warning {{unimplemented selector 'instNotOk'}}
+}
+@end
diff --git a/test/PCH/selector-warning.m b/test/PCH/selector-warning.m
new file mode 100644
index 0000000..413f64f
--- /dev/null
+++ b/test/PCH/selector-warning.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t.h.pch %S/selector-warning.h
+// RUN: %clang_cc1 -include-pch %t.h.pch %s
+
+@interface Bar
++ (void) clNotOk;
+- (void) instNotOk;
++ (void) cl1;
+@end
+
+@implementation Bar
+- (void) bar {}
++ (void) cl1 {}
++ (void) cl2 {}
+@end
+
+@implementation Bar(CAT)
+- (void) b1ar {}
+@end
+
OpenPOWER on IntegriCloud