1 // Test default argument instantiation in chained PCH.
2 
3 // Without PCH
4 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -include %s -include %s %s
5 
6 // With PCH
7 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -chain-include %s -chain-include %s
8 
9 // With modules
10 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fmodules %s -chain-include %s -chain-include %s
11 
12 // expected-no-diagnostics
13 
14 #ifndef HEADER1
15 #define HEADER1
16 //===----------------------------------------------------------------------===//
17 // Primary header.
18 
19 namespace rdar23810407 {
f(T t)20   template<typename T> int f(T t) {
21     extern T rdar23810407_variable;
22     return 0;
23   }
__anon1ae3f8f20102null24   template<typename T> int g(int a = f([] {}));
25 }
26 
27 //===----------------------------------------------------------------------===//
28 #elif not defined(HEADER2)
29 #define HEADER2
30 #if !defined(HEADER1)
31 #error Header inclusion order messed up
32 #endif
33 
34 //===----------------------------------------------------------------------===//
35 // Dependent header.
36 
instantiate_once()37 inline void instantiate_once() {
38   rdar23810407::g<int>();
39 }
40 
41 //===----------------------------------------------------------------------===//
42 #else
43 //===----------------------------------------------------------------------===//
44 
test()45 void test() {
46   rdar23810407::g<int>();
47 }
48 
49 //===----------------------------------------------------------------------===//
50 #endif
51