summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/Inputs/arc.h20
-rw-r--r--test/PCH/Inputs/typo.hpp8
-rw-r--r--test/PCH/arc.m9
-rw-r--r--test/PCH/typo.cpp17
-rw-r--r--test/PCH/variables.c34
-rw-r--r--test/PCH/variables.h1
6 files changed, 83 insertions, 6 deletions
diff --git a/test/PCH/Inputs/arc.h b/test/PCH/Inputs/arc.h
new file mode 100644
index 0000000..793fc64
--- /dev/null
+++ b/test/PCH/Inputs/arc.h
@@ -0,0 +1,20 @@
+// Header for Objective-C ARC-related PCH tests
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+@interface NSString
+@end
+
+id CreateSomething();
+NSString *CreateNSString();
+
+typedef int array0[sizeof((__bridge id)CFCreateSomething())];
+typedef int array1[sizeof((__bridge CFTypeRef)CreateSomething())];
+
+
diff --git a/test/PCH/Inputs/typo.hpp b/test/PCH/Inputs/typo.hpp
new file mode 100644
index 0000000..c811595
--- /dev/null
+++ b/test/PCH/Inputs/typo.hpp
@@ -0,0 +1,8 @@
+namespace boost {
+ template<typename F> class function {};
+
+ namespace graph {
+ template<typename V, typename E> class adjacency_list { };
+ };
+}
+
diff --git a/test/PCH/arc.m b/test/PCH/arc.m
new file mode 100644
index 0000000..6f7b870
--- /dev/null
+++ b/test/PCH/arc.m
@@ -0,0 +1,9 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-arc -include %S/Inputs/arc.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -fblocks -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-arc -x objective-c-header -o %t %S/Inputs/arc.h
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+array0 a0;
+array1 a1;
diff --git a/test/PCH/typo.cpp b/test/PCH/typo.cpp
new file mode 100644
index 0000000..4c88614
--- /dev/null
+++ b/test/PCH/typo.cpp
@@ -0,0 +1,17 @@
+
+// In header: expected-note{{ 'boost::function' declared here}}
+
+
+// In header: expected-note{{ 'boost::graph::adjacency_list' declared here}}
+
+
+
+adjacent_list<int, int> g; // expected-error{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}}
+Function<int(int)> f; // expected-error{{no template named 'Function'; did you mean 'boost::function'?}}
+
+// Without PCH
+// RUN: %clang_cc1 -include %S/Inputs/typo.hpp -verify %s
+
+// With PCH
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/typo.hpp
+// RUN: %clang_cc1 -include-pch %t -verify %s
diff --git a/test/PCH/variables.c b/test/PCH/variables.c
index 58fd8ae..9f90b37 100644
--- a/test/PCH/variables.c
+++ b/test/PCH/variables.c
@@ -1,18 +1,40 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/variables.h -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
// Test with pch.
-// RUN: %clang_cc1 -emit-pch -o %t %S/variables.h
+// RUN: %clang_cc1 -emit-pch -o %t %s
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+#ifndef HEADER
+#define HEADER
+
+extern float y;
+extern int *ip, x;
+
+float z; // expected-note{{previous}}
+
+int z2 = 17; // expected-note{{previous}}
+
+#define MAKE_HAPPY(X) X##Happy
+int MAKE_HAPPY(Very); // expected-note{{previous definition is here}}
+
+#define A_MACRO_IN_THE_PCH 492
+#define FUNCLIKE_MACRO(X, Y) X ## Y
+
+#define PASTE2(x,y) x##y
+#define PASTE1(x,y) PASTE2(x,y)
+#define UNIQUE(x) PASTE1(x,__COUNTER__)
+
+int UNIQUE(a); // a0
+int UNIQUE(a); // a1
+
+#else
+
int *ip2 = &x;
float *fp = &ip; // expected-warning{{incompatible pointer types}}
-// FIXME:variables.h expected-note{{previous}}
double z; // expected-error{{redefinition}}
-// FIXME:variables.h expected-note{{previous}}
int z2 = 18; // expected-error{{redefinition}}
double VeryHappy; // expected-error{{redefinition}}
-// FIXME:variables.h expected-note{{previous definition is here}}
int Q = A_MACRO_IN_THE_PCH;
@@ -21,3 +43,5 @@ int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
int UNIQUE(a); // a2
int *Arr[] = { &a0, &a1, &a2 };
+
+#endif
diff --git a/test/PCH/variables.h b/test/PCH/variables.h
index c937429..23d2cd3 100644
--- a/test/PCH/variables.h
+++ b/test/PCH/variables.h
@@ -23,4 +23,3 @@ int MAKE_HAPPY(Very);
int UNIQUE(a); // a0
int UNIQUE(a); // a1
-
OpenPOWER on IntegriCloud