diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-14 20:14:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-14 20:14:33 +0000 |
commit | 663b5a0be7261c29bc4c526a71cffcfa02d4153e (patch) | |
tree | 06582f834e2df99344af84881c6e6703502d84e2 /test/CXX | |
parent | 54150d9b1d308334d40864c8d8d8d6d1a9da363e (diff) |
Testing and some minor fixes for explicit template instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84129 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp | 10 | ||||
-rw-r--r-- | test/CXX/temp/temp.spec/temp.explicit/p1.cpp | 89 |
2 files changed, 99 insertions, 0 deletions
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp new file mode 100644 index 0000000000..becdd6b606 --- /dev/null +++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc -fsyntax-only -std=c++0x -verify %s + +template<typename T> +struct X { + void f(); +}; + +template inline void X<int>::f(); // expected-error{{'inline'}} + +// FIXME: test constexpr diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp new file mode 100644 index 0000000000..896e30efb8 --- /dev/null +++ b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp @@ -0,0 +1,89 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +struct C { }; + +template<typename T> +struct X0 { + T value; // expected-error{{incomplete}} +}; + +// Explicitly instantiate a class template specialization +template struct X0<int>; +template struct X0<void>; // expected-note{{instantiation}} + +// Explicitly instantiate a function template specialization +template<typename T> +void f0(T t) { + ++t; // expected-error{{cannot modify}} +} + +template void f0(int); +template void f0<long>(long); +template void f0<>(unsigned); +template void f0(int C::*); // expected-note{{instantiation}} + +// Explicitly instantiate a member template specialization +template<typename T> +struct X1 { + template<typename U> + struct Inner { + T member1; + U member2; // expected-error{{incomplete}} + }; + + template<typename U> + void f(T& t, U u) { + t = u; // expected-error{{incompatible}} + } +}; + +template struct X1<int>::Inner<float>; +template struct X1<int>::Inner<double>; +template struct X1<int>::Inner<void>; // expected-note{{instantiation}} + +template void X1<int>::f(int&, float); +template void X1<int>::f<long>(int&, long); +template void X1<int>::f<>(int&, double); +template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}} + +// Explicitly instantiate members of a class template +struct Incomplete; // expected-note{{forward declaration}} +struct NonDefaultConstructible { + NonDefaultConstructible(int); +}; + +template<typename T, typename U> +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<typename T, typename U> +T X2<T, U>::static_member1 = 17; // expected-error{{incompatible type}} + +template<typename T, typename U> +U X2<T, U>::static_member2; // expected-error{{no matching}} + +template void X2<int, float>::f(int &, float); +template void X2<int, float>::f(int &, double); // expected-error{{does not refer}} +template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}} + +template struct X2<int, float>::Inner; +template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}} + +template int X2<int, float>::static_member1; +template int* X2<int*, float>::static_member1; // expected-note{{instantiation}} +template + NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1; + +template + NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}} |