]> granicus.if.org Git - clang/commitdiff
Add PCH tests for R336379
authorErich Keane <erich.keane@intel.com>
Thu, 5 Jul 2018 17:23:15 +0000 (17:23 +0000)
committerErich Keane <erich.keane@intel.com>
Thu, 5 Jul 2018 17:23:15 +0000 (17:23 +0000)
I seemingly forgot the tests for this commit, added here.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336380 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
test/PCH/Inputs/pch-through-use0.cpp [new file with mode: 0644]
test/PCH/Inputs/pch-through-use1.cpp [new file with mode: 0644]
test/PCH/Inputs/pch-through-use2.cpp [new file with mode: 0644]
test/PCH/Inputs/pch-through-use3a.cpp [new file with mode: 0644]
test/PCH/Inputs/pch-through-use3b.cpp [new file with mode: 0644]
test/PCH/Inputs/pch-through1.h [new file with mode: 0644]
test/PCH/Inputs/pch-through2.h [new file with mode: 0644]
test/PCH/Inputs/pch-through3.h [new file with mode: 0644]
test/PCH/Inputs/pch-through4.h [new file with mode: 0644]
test/PCH/pch-through1.cpp [new file with mode: 0644]
test/PCH/pch-through2.cpp [new file with mode: 0644]
test/PCH/pch-through3a.cpp [new file with mode: 0644]
test/PCH/pch-through3b.cpp [new file with mode: 0644]

diff --git a/test/PCH/Inputs/pch-through-use0.cpp b/test/PCH/Inputs/pch-through-use0.cpp
new file mode 100644 (file)
index 0000000..a390801
--- /dev/null
@@ -0,0 +1,2 @@
+void foo() {
+}
diff --git a/test/PCH/Inputs/pch-through-use1.cpp b/test/PCH/Inputs/pch-through-use1.cpp
new file mode 100644 (file)
index 0000000..4eda7ce
--- /dev/null
@@ -0,0 +1,5 @@
+#include "Inputs/pch-through1.h"
+#include "Inputs/pch-through3.h"
+void foo() {
+  through2(0);
+}
diff --git a/test/PCH/Inputs/pch-through-use2.cpp b/test/PCH/Inputs/pch-through-use2.cpp
new file mode 100644 (file)
index 0000000..217803b
--- /dev/null
@@ -0,0 +1,3 @@
+void foo() {
+  through4(0);
+}
diff --git a/test/PCH/Inputs/pch-through-use3a.cpp b/test/PCH/Inputs/pch-through-use3a.cpp
new file mode 100644 (file)
index 0000000..dfd1d11
--- /dev/null
@@ -0,0 +1,2 @@
+#define AFOO 0
+#include "Inputs/pch-through1.h"
diff --git a/test/PCH/Inputs/pch-through-use3b.cpp b/test/PCH/Inputs/pch-through-use3b.cpp
new file mode 100644 (file)
index 0000000..5b54764
--- /dev/null
@@ -0,0 +1,3 @@
+#define AFOO 1
+#define BFOO 2
+#include "Inputs/pch-through1.h"
diff --git a/test/PCH/Inputs/pch-through1.h b/test/PCH/Inputs/pch-through1.h
new file mode 100644 (file)
index 0000000..7ebfa7d
--- /dev/null
@@ -0,0 +1,2 @@
+#define THROUGH1
+int through1(int);
diff --git a/test/PCH/Inputs/pch-through2.h b/test/PCH/Inputs/pch-through2.h
new file mode 100644 (file)
index 0000000..4c1f298
--- /dev/null
@@ -0,0 +1,2 @@
+#define THROUGH2
+int through2(int);
diff --git a/test/PCH/Inputs/pch-through3.h b/test/PCH/Inputs/pch-through3.h
new file mode 100644 (file)
index 0000000..2836865
--- /dev/null
@@ -0,0 +1,2 @@
+#define THROUGH3
+int through3(int);
diff --git a/test/PCH/Inputs/pch-through4.h b/test/PCH/Inputs/pch-through4.h
new file mode 100644 (file)
index 0000000..95860ed
--- /dev/null
@@ -0,0 +1,2 @@
+#define THROUGH4
+int through4(int);
diff --git a/test/PCH/pch-through1.cpp b/test/PCH/pch-through1.cpp
new file mode 100644 (file)
index 0000000..b7e7fa8
--- /dev/null
@@ -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/test/PCH/pch-through2.cpp b/test/PCH/pch-through2.cpp
new file mode 100644 (file)
index 0000000..6bf7a29
--- /dev/null
@@ -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/test/PCH/pch-through3a.cpp b/test/PCH/pch-through3a.cpp
new file mode 100644 (file)
index 0000000..3a134e9
--- /dev/null
@@ -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/test/PCH/pch-through3b.cpp b/test/PCH/pch-through3b.cpp
new file mode 100644 (file)
index 0000000..2a7695a
--- /dev/null
@@ -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"