From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp (limited to 'clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp') diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp new file mode 100644 index 0000000..38ae768 --- /dev/null +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp @@ -0,0 +1,81 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s + +// A declaration of a function template shall be in scope at the point of the +// explicit instantiation of the function template. +template void f0(T); +template void f0(int); // okay +template void f0(T) { } + +// A definition of the class or class template containing a member function +// template shall be in scope at the point of the explicit instantiation of +// the member function template. +struct X0; // expected-note {{forward declaration}} +template struct X1; // expected-note 5{{declared here}} + +template void X0::f0(int); // expected-error {{incomplete type}} +template void X1::f0(int); // expected-error {{implicit instantiation of undefined template}} + +// A definition of a class template or class member template shall be in scope +// at the point of the explicit instantiation of the class template or class +// member template. +template struct X1; // expected-error{{explicit instantiation of undefined template}} + +template +struct X2 { // expected-note 4{{refers here}} + template + struct Inner; // expected-note{{declared here}} + + struct InnerClass; // expected-note{{forward declaration}} +}; + +template struct X2::Inner; // expected-error{{explicit instantiation of undefined template}} + +// A definition of a class template shall be in scope at the point of an +// explicit instantiation of a member function or a static data member of the +// class template. +template void X1::f1(int); // expected-error {{undefined template}} +template void X1::f1(int); // expected-error {{undefined template}} + +template int X1::member; // expected-error {{undefined template}} + +// A definition of a member class of a class template shall be in scope at the +// point of an explicit instantiation of the member class. +template struct X2::InnerClass; // expected-error{{undefined member}} + +// If the declaration of the explicit instantiation names an implicitly-declared +// special member function (Clause 12), the program is ill-formed. +template X2::X2(); // expected-error{{not an instantiation}} +template X2::X2(const X2&); // expected-error{{not an instantiation}} +template X2::~X2(); // expected-error{{not an instantiation}} +template X2 &X2::operator=(const X2&); // expected-error{{not an instantiation}} + + +// A definition of a class template is sufficient to explicitly +// instantiate a member of the class template which itself is not yet defined. +namespace PR7979 { + template struct S { + void f(); + static void g(); + static int i; + struct S2 { + void h(); + }; + }; + + template void S::f(); + template void S::g(); + template int S::i; + template void S::S2::h(); + + template void S::f() {} + template void S::g() {} + template int S::i; + template void S::S2::h() {} +} + +namespace PR11599 { + template class BasicStringPiece; // expected-note {{template is declared here}} + + extern template class BasicStringPiece; // expected-error{{explicit instantiation of undefined template 'PR11599::BasicStringPiece}} + template class BasicStringPiece; +} -- cgit v1.2.3