diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-05-14 15:04:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-05-14 15:04:18 +0000 |
commit | 0c4a34b1a089fa5cb675048feec2131d1a6f9150 (patch) | |
tree | f31b28fca54fd51cca5f55da834fae01e5398d77 /clang/test/SemaTemplate/alias-templates.cpp | |
parent | 6c4c6a8047f1c0a99dd092227ce06015e471bf17 (diff) | |
download | bcm5719-llvm-0c4a34b1a089fa5cb675048feec2131d1a6f9150.tar.gz bcm5719-llvm-0c4a34b1a089fa5cb675048feec2131d1a6f9150.zip |
PR9908: Fix the broken fix for PR9902 to get the template argument lists in the right order.
Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers.
llvm-svn: 131342
Diffstat (limited to 'clang/test/SemaTemplate/alias-templates.cpp')
-rw-r--r-- | clang/test/SemaTemplate/alias-templates.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/alias-templates.cpp b/clang/test/SemaTemplate/alias-templates.cpp new file mode 100644 index 00000000000..f4c917c5ebc --- /dev/null +++ b/clang/test/SemaTemplate/alias-templates.cpp @@ -0,0 +1,70 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template<typename S> +struct A { + typedef S B; + template<typename T> using C = typename T::B; + template<typename T> struct D { + template<typename U> using E = typename A<U>::template C<A<T>>; + template<typename U> using F = A<E<U>>; + template<typename U> using G = C<F<U>>; + G<T> g; + }; + typedef decltype(D<B>().g) H; + D<H> h; + template<typename T> using I = A<decltype(h.g)>; + template<typename T> using J = typename A<decltype(h.g)>::template C<I<T>>; +}; + +A<int> a; +A<char>::D<double> b; + +template<typename T> T make(); + +namespace X { + template<typename T> struct traits { + typedef T thing; + typedef decltype(val(make<thing>())) inner_ptr; + + template<typename U> using rebind_thing = typename thing::template rebind<U>; + template<typename U> using rebind = traits<rebind_thing<U>>; + + inner_ptr &&alloc(); + void free(inner_ptr&&); + }; + + template<typename T> struct ptr_traits { + typedef T *type; + }; + template<typename T> using ptr = typename ptr_traits<T>::type; + + template<typename T> struct thing { + typedef T inner; + typedef ptr<inner> inner_ptr; + typedef traits<thing<inner>> traits_type; + + template<typename U> using rebind = thing<U>; + + thing(traits_type &traits) : traits(traits), val(traits.alloc()) {} + ~thing() { traits.free(static_cast<inner_ptr&&>(val)); } + + traits_type &traits; + inner_ptr val; + + friend inner_ptr val(const thing &t) { return t.val; } + }; + + template<> struct ptr_traits<bool> { + typedef bool &type; + }; + template<> bool &traits<thing<bool>>::alloc() { static bool b; return b; } + template<> void traits<thing<bool>>::free(bool&) {} +} + +typedef X::traits<X::thing<int>> itt; + +itt::thing::traits_type itr; +itt::thing ith(itr); + +itt::rebind<bool> btr; +itt::rebind_thing<bool> btt(btr); |