29 lines · cpp
1// Test this without pch, template will be instantiated.2// RUN: %clang_cc1 -fsyntax-only %s -verify=expected3 4// Test with pch, template will be instantiated in the TU.5// RUN: %clang_cc1 -emit-pch -o %t %s -verify=ok6// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s -verify=expected7 8// Test with pch with template instantiation in the pch.9// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s -verify=expected10 11// ok-no-diagnostics12 13#ifndef HEADER_H14#define HEADER_H15 16template <typename T>17struct A {18 T foo() const { return "test"; } // @1819};20 21double bar(A<double> *a) {22 return a->foo(); // @2223}24 25#endif26 27// expected-error@18 {{cannot initialize return object}}28// expected-note@22 {{in instantiation of member function}}29