summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/test/PCH/Inputs/pch-through-use0.cpp2
-rw-r--r--clang/test/PCH/Inputs/pch-through-use1.cpp5
-rw-r--r--clang/test/PCH/Inputs/pch-through-use2.cpp3
-rw-r--r--clang/test/PCH/Inputs/pch-through-use3a.cpp2
-rw-r--r--clang/test/PCH/Inputs/pch-through-use3b.cpp3
-rw-r--r--clang/test/PCH/Inputs/pch-through1.h2
-rw-r--r--clang/test/PCH/Inputs/pch-through2.h2
-rw-r--r--clang/test/PCH/Inputs/pch-through3.h2
-rw-r--r--clang/test/PCH/Inputs/pch-through4.h2
-rw-r--r--clang/test/PCH/pch-through1.cpp34
-rw-r--r--clang/test/PCH/pch-through2.cpp28
-rw-r--r--clang/test/PCH/pch-through3a.cpp10
-rw-r--r--clang/test/PCH/pch-through3b.cpp14
13 files changed, 109 insertions, 0 deletions
diff --git a/clang/test/PCH/Inputs/pch-through-use0.cpp b/clang/test/PCH/Inputs/pch-through-use0.cpp
new file mode 100644
index 00000000000..a39080144fb
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through-use0.cpp
@@ -0,0 +1,2 @@
+void foo() {
+}
diff --git a/clang/test/PCH/Inputs/pch-through-use1.cpp b/clang/test/PCH/Inputs/pch-through-use1.cpp
new file mode 100644
index 00000000000..4eda7cecc95
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through-use1.cpp
@@ -0,0 +1,5 @@
+#include "Inputs/pch-through1.h"
+#include "Inputs/pch-through3.h"
+void foo() {
+ through2(0);
+}
diff --git a/clang/test/PCH/Inputs/pch-through-use2.cpp b/clang/test/PCH/Inputs/pch-through-use2.cpp
new file mode 100644
index 00000000000..217803ba398
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through-use2.cpp
@@ -0,0 +1,3 @@
+void foo() {
+ through4(0);
+}
diff --git a/clang/test/PCH/Inputs/pch-through-use3a.cpp b/clang/test/PCH/Inputs/pch-through-use3a.cpp
new file mode 100644
index 00000000000..dfd1d11071c
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through-use3a.cpp
@@ -0,0 +1,2 @@
+#define AFOO 0
+#include "Inputs/pch-through1.h"
diff --git a/clang/test/PCH/Inputs/pch-through-use3b.cpp b/clang/test/PCH/Inputs/pch-through-use3b.cpp
new file mode 100644
index 00000000000..5b547647d85
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through-use3b.cpp
@@ -0,0 +1,3 @@
+#define AFOO 1
+#define BFOO 2
+#include "Inputs/pch-through1.h"
diff --git a/clang/test/PCH/Inputs/pch-through1.h b/clang/test/PCH/Inputs/pch-through1.h
new file mode 100644
index 00000000000..7ebfa7d5df2
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through1.h
@@ -0,0 +1,2 @@
+#define THROUGH1
+int through1(int);
diff --git a/clang/test/PCH/Inputs/pch-through2.h b/clang/test/PCH/Inputs/pch-through2.h
new file mode 100644
index 00000000000..4c1f2981f93
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through2.h
@@ -0,0 +1,2 @@
+#define THROUGH2
+int through2(int);
diff --git a/clang/test/PCH/Inputs/pch-through3.h b/clang/test/PCH/Inputs/pch-through3.h
new file mode 100644
index 00000000000..28368655004
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through3.h
@@ -0,0 +1,2 @@
+#define THROUGH3
+int through3(int);
diff --git a/clang/test/PCH/Inputs/pch-through4.h b/clang/test/PCH/Inputs/pch-through4.h
new file mode 100644
index 00000000000..95860edd196
--- /dev/null
+++ b/clang/test/PCH/Inputs/pch-through4.h
@@ -0,0 +1,2 @@
+#define THROUGH4
+int through4(int);
diff --git a/clang/test/PCH/pch-through1.cpp b/clang/test/PCH/pch-through1.cpp
new file mode 100644
index 00000000000..b7e7fa82a19
--- /dev/null
+++ b/clang/test/PCH/pch-through1.cpp
@@ -0,0 +1,34 @@
+// Through header not found (anywhere)
+// RUN: not %clang_cc1 -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-does-not-exist.h -o %t %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-TEST0A %s
+// CHECK-TEST0A: fatal error:{{.*}} 'Inputs/pch-does-not-exist.h'
+// CHECK-TEST0A-SAME: required for precompiled header not found
+
+// Through header not found in search path
+// RUN: not %clang_cc1 -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through2.h -o %t \
+// RUN: %S/Inputs/pch-through-use0.cpp 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-TEST0B %s
+// CHECK-TEST0B: fatal error:{{.*}}'Inputs/pch-through2.h'
+// CHECK-TEST0B-SAME: required for precompiled header not found
+
+// No #include of through header during pch create
+// RUN: not %clang_cc1 -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through2.h -o %t %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-TEST1A %s
+// CHECK-TEST1A: fatal error:{{.*}} #include of
+// CHECK-TEST1A-SAME: 'Inputs/pch-through2.h' not seen while attempting to
+// CHECK-TEST1A-SAME: create precompiled header
+
+// checks for through headers that are also -includes
+// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \
+// RUN: -pch-through-header=Inputs/pch-through1.h -emit-pch -o %t.s3t1 %s
+// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \
+// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through3.h \
+// RUN: -pch-through-header=Inputs/pch-through2.h -emit-pch -o %t.s3t2 %s
+// Use through header from -includes
+// RUN: %clang_cc1 -I %S -include Inputs/pch-through1.h \
+// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through4.h \
+// RUN: -pch-through-header=Inputs/pch-through2.h -include-pch %t.s3t2 \
+// RUN: %S/Inputs/pch-through-use2.cpp -o %t.out
diff --git a/clang/test/PCH/pch-through2.cpp b/clang/test/PCH/pch-through2.cpp
new file mode 100644
index 00000000000..6bf7a29d9a0
--- /dev/null
+++ b/clang/test/PCH/pch-through2.cpp
@@ -0,0 +1,28 @@
+// Create
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through2.h -o %t.1 %s
+
+// Use
+// RUN: %clang_cc1 -I %S -include-pch %t.1 \
+// RUN: -pch-through-header=Inputs/pch-through2.h %s
+
+// No #include of through header during pch use
+// RUN: not %clang_cc1 -I %S -include-pch %t.1 \
+// RUN: -pch-through-header=Inputs/pch-through2.h \
+// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-TEST2A %s
+// CHECK-TEST2A: fatal error:{{.*}} #include of
+// CHECK-TEST2A-SAME: 'Inputs/pch-through2.h' not seen while attempting to
+// CHECK-TEST2A-SAME: use precompiled header
+
+// check that pch only contains code before the through header.
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.2 %s
+// RUN: not %clang_cc1 -I %S -include-pch %t.2 \
+// RUN: -pch-through-header=Inputs/pch-through1.h \
+// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-TEST3 %s
+// CHECK-TEST3: error: use of undeclared identifier 'through2'
+
+#include "Inputs/pch-through1.h"
+#include "Inputs/pch-through2.h"
diff --git a/clang/test/PCH/pch-through3a.cpp b/clang/test/PCH/pch-through3a.cpp
new file mode 100644
index 00000000000..3a134e9310b
--- /dev/null
+++ b/clang/test/PCH/pch-through3a.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.s3at1 %s
+
+// RUN: %clang_cc1 -I %S -include-pch %t.s3at1 \
+// RUN: -pch-through-header=Inputs/pch-through1.h \
+// RUN: %S/Inputs/pch-through-use3a.cpp
+//expected-no-diagnostics
+
+#define AFOO 0
+#include "Inputs/pch-through1.h"
diff --git a/clang/test/PCH/pch-through3b.cpp b/clang/test/PCH/pch-through3b.cpp
new file mode 100644
index 00000000000..2a7695a7098
--- /dev/null
+++ b/clang/test/PCH/pch-through3b.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.s3bt1 %s
+
+// RUN: %clang_cc1 -I %S -include-pch %t.s3bt1 \
+// RUN: -pch-through-header=Inputs/pch-through1.h \
+// RUN: %S/Inputs/pch-through-use3b.cpp 2>&1 | FileCheck %s
+
+//CHECK: warning: definition of macro 'AFOO' does not match definition in
+//CHECK-SAME: precompiled header
+//CHECK: warning: definition of macro 'BFOO' does not match definition in
+//CHECK-SAME: precompiled header
+
+#define AFOO 0
+#include "Inputs/pch-through1.h"
OpenPOWER on IntegriCloud