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/p1.cpp | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp (limited to 'clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp') diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp new file mode 100644 index 0000000..b426339 --- /dev/null +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct C { }; + +template +struct X0 { + T value; // expected-error{{incomplete}} +}; + +// Explicitly instantiate a class template specialization +template struct X0; +template struct X0; // expected-note{{instantiation}} + +// Explicitly instantiate a function template specialization +template +void f0(T t) { + ++t; // expected-error{{cannot increment}} +} + +template void f0(int); +template void f0(long); +template void f0<>(unsigned); +template void f0(int C::*); // expected-note{{instantiation}} + +// Explicitly instantiate a member template specialization +template +struct X1 { + template + struct Inner { + T member1; + U member2; // expected-error{{incomplete}} + }; + + template + void f(T& t, U u) { + t = u; // expected-error{{incompatible}} + } +}; + +template struct X1::Inner; +template struct X1::Inner; +template struct X1::Inner; // expected-note{{instantiation}} + +template void X1::f(int&, float); +template void X1::f(int&, long); +template void X1::f<>(int&, double); +template void X1::f<>(int&, int*); // expected-note{{instantiation}} + +// Explicitly instantiate members of a class template +struct Incomplete; // expected-note{{forward declaration}} +struct NonDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor) not viable}} + NonDefaultConstructible(int); // expected-note{{candidate constructor}} +}; + +template +struct X2 { + void f(T &t, U u) { + t = u; // expected-error{{incompatible}} + } + + struct Inner { + T member1; + U member2; // expected-error{{incomplete}} + }; + + static T static_member1; + static U static_member2; +}; + +template +T X2::static_member1 = 17; // expected-error{{cannot initialize}} + +template +U X2::static_member2; // expected-error{{no matching}} + +template void X2::f(int &, float); +template void X2::f(int &, double); // expected-error{{does not refer}} +template void X2::f(int&, int*); // expected-note{{instantiation}} + +template struct X2::Inner; +template struct X2::Inner; // expected-note{{instantiation}} + +template int X2::static_member1; +template int* X2::static_member1; // expected-note{{instantiation}} +template + NonDefaultConstructible X2::static_member1; + +template + NonDefaultConstructible X2::static_member2; // expected-note{{instantiation}} -- cgit v1.2.3