1 // No PCH:
2 // RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s
3 //
4 // With chained PCH:
5 // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t.a
6 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch %s -o %t.b
7 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s
8 
9 // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates %s -o %t.a
10 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch -fpch-instantiate-templates %s -o %t.b
11 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s
12 
13 // expected-no-diagnostics
14 
15 #if !defined(HEADER1)
16 #define HEADER1
17 
18 auto &f(int &);
19 
g(T & t)20 template<typename T> decltype(auto) g(T &t) {
21   return f(t);
22 }
23 
24 #elif !defined(HEADER2)
25 #define HEADER2
26 
27 // Ensure that this provides an update record for the type of HEADER1's 'f',
28 // so that HEADER1's 'g' can successfully call it.
f(int & n)29 auto &f(int &n) {
30   return n;
31 }
32 
33 #else
34 
35 int n;
36 int &k = g(n);
37 
38 #endif
39