1 // Test this without pch.
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -DBODY %s -o - | FileCheck %s
3 
4 // Test with pch.
5 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t %s
6 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY %s -o - | FileCheck %s
7 
8 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -fpch-instantiate-templates -o %t %s
9 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY %s -o - | FileCheck %s
10 
11 // expected-no-diagnostics
12 
13 #ifndef HEADER_H
14 #define HEADER_H
15 struct A {
fooA16   void foo() { bar<0>(); } // This will trigger implicit instantiation of bar<0>() in the PCH.
17   template <int N>
18   void bar();
19 };
20 #endif
21 
22 #ifdef BODY
23 // But the definition is only in the source, so the instantiation must be delayed until the TU.
24 template <int N>
bar()25 void A::bar() {}
26 
test(A * a)27 void test(A *a) { a->foo(); }
28 #endif
29 
30 // CHECK: define linkonce_odr void @_ZN1A3barILi0EEEvv
31