diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-29 00:04:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-29 00:04:11 +0000 |
commit | 21610380de972a5307dfb07f446b44fbe2989be5 (patch) | |
tree | 95c3192bec0dc12a820a0f05839d4c2fec861d6d /clang/test/CXX/temp/temp.decls | |
parent | 6c4d255bf3d64fd2ecb48334e780c87f060f1280 (diff) | |
download | bcm5719-llvm-21610380de972a5307dfb07f446b44fbe2989be5.tar.gz bcm5719-llvm-21610380de972a5307dfb07f446b44fbe2989be5.zip |
Implement support for semantic checking and template instantiation of
class template partial specializations of member templates. Also,
fixes a silly little bug in the marking of "used" template parameters
in member templates. Fixes PR5236.
llvm-svn: 85447
Diffstat (limited to 'clang/test/CXX/temp/temp.decls')
-rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp index afe6ab2b968..79d6c54e29f 100644 --- a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp @@ -1,5 +1,6 @@ // RUN: clang-cc -fsyntax-only -verify %s +// Test class template partial specializations of member templates. template<typename T> struct X0 { template<typename U> struct Inner0 { @@ -16,5 +17,39 @@ struct X0<T>::Inner0<const U*> { static const unsigned value = 2; }; -// FIXME: Test instantiation of these partial specializations (once they are -// implemented). +int array0[X0<int>::Inner0<int>::value == 0? 1 : -1]; +int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1]; +int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1]; + +// Make sure we can provide out-of-line class template partial specializations +// for member templates (and instantiate them). +template<class T> struct A { + struct C { + template<class T2> struct B; + }; +}; + +// partial specialization of A<T>::C::B<T2> +template<class T> template<class T2> struct A<T>::C::B<T2*> { }; + +A<short>::C::B<int*> absip; + +// Check for conflicts during template instantiation. +template<typename T, typename U> +struct Outer { + template<typename X, typename Y> struct Inner; + template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}} + template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}} +}; + +Outer<int, int> outer; // expected-note{{instantiation}} + +// Test specialization of class template partial specialization members. +template<> template<typename Z> +struct X0<float>::Inner0<Z*> { + static const unsigned value = 3; +}; + +int array3[X0<float>::Inner0<int>::value == 0? 1 : -1]; +int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1]; +int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1]; |