[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / pch-instantiate-templates.cpp
blob20aadf83bdb8744dcabc4c39770d6a0018f5d6a9
1 // Test this without pch, template will be instantiated.
2 // RUN: %clang_cc1 -fsyntax-only %s -verify=expected
4 // Test with pch, template will be instantiated in the TU.
5 // RUN: %clang_cc1 -emit-pch -o %t %s -verify=ok
6 // RUN: %clang_cc1 -include-pch %t -fsyntax-only %s -verify=expected
8 // Test with pch with template instantiation in the pch.
9 // RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s -verify=expected
11 // ok-no-diagnostics
13 #ifndef HEADER_H
14 #define HEADER_H
16 template <typename T>
17 struct A {
18 T foo() const { return "test"; } // @18
21 double bar(A<double> *a) {
22 return a->foo(); // @22
25 #endif
27 // expected-error@18 {{cannot initialize return object}}
28 // expected-note@22 {{in instantiation of member function}}