summaryrefslogtreecommitdiffstats
path: root/clang/test/PCH/chain-default-argument-instantiation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/PCH/chain-default-argument-instantiation.cpp')
-rw-r--r--clang/test/PCH/chain-default-argument-instantiation.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/PCH/chain-default-argument-instantiation.cpp b/clang/test/PCH/chain-default-argument-instantiation.cpp
new file mode 100644
index 00000000000..0accd544a38
--- /dev/null
+++ b/clang/test/PCH/chain-default-argument-instantiation.cpp
@@ -0,0 +1,50 @@
+// Test default argument instantiation in chained PCH.
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -chain-include %s -chain-include %s
+
+// With modules
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fmodules %s -chain-include %s -chain-include %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header.
+
+namespace rdar23810407 {
+ template<typename T> int f(T t) {
+ extern T rdar23810407_variable;
+ return 0;
+ }
+ template<typename T> int g(int a = f([] {}));
+}
+
+//===----------------------------------------------------------------------===//
+#elif not defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header.
+
+inline void instantiate_once() {
+ rdar23810407::g<int>();
+}
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void test() {
+ rdar23810407::g<int>();
+}
+
+//===----------------------------------------------------------------------===//
+#endif
OpenPOWER on IntegriCloud