From 6aaa2f4b453456b0f82b4ffcef4c8fa10c94bfc7 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Thu, 5 Jul 2018 17:23:15 +0000 Subject: [PATCH] Add PCH tests for R336379 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 --- test/PCH/Inputs/pch-through-use0.cpp | 2 ++ test/PCH/Inputs/pch-through-use1.cpp | 5 ++++ test/PCH/Inputs/pch-through-use2.cpp | 3 +++ test/PCH/Inputs/pch-through-use3a.cpp | 2 ++ test/PCH/Inputs/pch-through-use3b.cpp | 3 +++ test/PCH/Inputs/pch-through1.h | 2 ++ test/PCH/Inputs/pch-through2.h | 2 ++ test/PCH/Inputs/pch-through3.h | 2 ++ test/PCH/Inputs/pch-through4.h | 2 ++ test/PCH/pch-through1.cpp | 34 +++++++++++++++++++++++++++ test/PCH/pch-through2.cpp | 28 ++++++++++++++++++++++ test/PCH/pch-through3a.cpp | 10 ++++++++ test/PCH/pch-through3b.cpp | 14 +++++++++++ 13 files changed, 109 insertions(+) create mode 100644 test/PCH/Inputs/pch-through-use0.cpp create mode 100644 test/PCH/Inputs/pch-through-use1.cpp create mode 100644 test/PCH/Inputs/pch-through-use2.cpp create mode 100644 test/PCH/Inputs/pch-through-use3a.cpp create mode 100644 test/PCH/Inputs/pch-through-use3b.cpp create mode 100644 test/PCH/Inputs/pch-through1.h create mode 100644 test/PCH/Inputs/pch-through2.h create mode 100644 test/PCH/Inputs/pch-through3.h create mode 100644 test/PCH/Inputs/pch-through4.h create mode 100644 test/PCH/pch-through1.cpp create mode 100644 test/PCH/pch-through2.cpp create mode 100644 test/PCH/pch-through3a.cpp create mode 100644 test/PCH/pch-through3b.cpp diff --git a/test/PCH/Inputs/pch-through-use0.cpp b/test/PCH/Inputs/pch-through-use0.cpp new file mode 100644 index 0000000000..a39080144f --- /dev/null +++ b/test/PCH/Inputs/pch-through-use0.cpp @@ -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 index 0000000000..4eda7cecc9 --- /dev/null +++ b/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/test/PCH/Inputs/pch-through-use2.cpp b/test/PCH/Inputs/pch-through-use2.cpp new file mode 100644 index 0000000000..217803ba39 --- /dev/null +++ b/test/PCH/Inputs/pch-through-use2.cpp @@ -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 index 0000000000..dfd1d11071 --- /dev/null +++ b/test/PCH/Inputs/pch-through-use3a.cpp @@ -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 index 0000000000..5b547647d8 --- /dev/null +++ b/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/test/PCH/Inputs/pch-through1.h b/test/PCH/Inputs/pch-through1.h new file mode 100644 index 0000000000..7ebfa7d5df --- /dev/null +++ b/test/PCH/Inputs/pch-through1.h @@ -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 index 0000000000..4c1f2981f9 --- /dev/null +++ b/test/PCH/Inputs/pch-through2.h @@ -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 index 0000000000..2836865500 --- /dev/null +++ b/test/PCH/Inputs/pch-through3.h @@ -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 index 0000000000..95860edd19 --- /dev/null +++ b/test/PCH/Inputs/pch-through4.h @@ -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 index 0000000000..b7e7fa82a1 --- /dev/null +++ b/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/test/PCH/pch-through2.cpp b/test/PCH/pch-through2.cpp new file mode 100644 index 0000000000..6bf7a29d9a --- /dev/null +++ b/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/test/PCH/pch-through3a.cpp b/test/PCH/pch-through3a.cpp new file mode 100644 index 0000000000..3a134e9310 --- /dev/null +++ b/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/test/PCH/pch-through3b.cpp b/test/PCH/pch-through3b.cpp new file mode 100644 index 0000000000..2a7695a709 --- /dev/null +++ b/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" -- 2.40.0