// RUN: %clang_cc1 -fsyntax-only -verify %s // Verify that the "previous explicit instantiation" note points to the first // explicit instantiation statement, not to the implicit instantiation site. namespace GH21133 { template void f() {} void use_f() { f(); } template void f(); // expected-note{{previous explicit instantiation is here}} template void f(); // expected-error{{duplicate explicit instantiation of 'f'}} template struct S {}; void use_S(S) {} template struct S; // expected-note{{previous explicit instantiation is here}} template struct S; // expected-error{{duplicate explicit instantiation of 'S'}} template T var = T{}; int use_var = var; template int var; // expected-note{{previous explicit instantiation is here}} template int var; // expected-error{{duplicate explicit instantiation of 'var'}} namespace ns { template void g() {} } void use_g() { ns::g(); } template void ns::g(); // expected-note{{previous explicit instantiation is here}} template void ns::g(); // expected-error{{duplicate explicit instantiation of 'g'}} template struct Outer { template void f(U); template static U var; template struct Inner {}; }; template template void Outer::f(U) {} template template U Outer::var = U{}; void use_members() { Outer o; o.f(1.0); (void)Outer::var; Outer::Inner inner; } template void Outer::f(double); // expected-note{{previous explicit instantiation is here}} template void Outer::f(double); // expected-error{{duplicate explicit instantiation of 'f'}} template double Outer::var; // expected-note{{previous explicit instantiation is here}} template double Outer::var; // expected-error{{duplicate explicit instantiation of 'var'}} template struct Outer::Inner; // expected-note{{previous explicit instantiation is here}} template struct Outer::Inner; // expected-error{{duplicate explicit instantiation of 'Inner'}} template struct A { template struct B { template void f(V); }; }; template template template void A::B::f(V) {} void use_nested() { A::B b; b.f(1.0f); } template void A::B::f(float); // expected-note{{previous explicit instantiation is here}} template void A::B::f(float); // expected-error{{duplicate explicit instantiation of 'f'}} } // namespace GH21133