From 0c4a34b1a089fa5cb675048feec2131d1a6f9150 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 14 May 2011 15:04:18 +0000 Subject: 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 --- clang/test/SemaTemplate/alias-templates.cpp | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 clang/test/SemaTemplate/alias-templates.cpp (limited to 'clang/test/SemaTemplate/alias-templates.cpp') 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 +struct A { + typedef S B; + template using C = typename T::B; + template struct D { + template using E = typename A::template C>; + template using F = A>; + template using G = C>; + G g; + }; + typedef decltype(D().g) H; + D h; + template using I = A; + template using J = typename A::template C>; +}; + +A a; +A::D b; + +template T make(); + +namespace X { + template struct traits { + typedef T thing; + typedef decltype(val(make())) inner_ptr; + + template using rebind_thing = typename thing::template rebind; + template using rebind = traits>; + + inner_ptr &&alloc(); + void free(inner_ptr&&); + }; + + template struct ptr_traits { + typedef T *type; + }; + template using ptr = typename ptr_traits::type; + + template struct thing { + typedef T inner; + typedef ptr inner_ptr; + typedef traits> traits_type; + + template using rebind = thing; + + thing(traits_type &traits) : traits(traits), val(traits.alloc()) {} + ~thing() { traits.free(static_cast(val)); } + + traits_type &traits; + inner_ptr val; + + friend inner_ptr val(const thing &t) { return t.val; } + }; + + template<> struct ptr_traits { + typedef bool &type; + }; + template<> bool &traits>::alloc() { static bool b; return b; } + template<> void traits>::free(bool&) {} +} + +typedef X::traits> itt; + +itt::thing::traits_type itr; +itt::thing ith(itr); + +itt::rebind btr; +itt::rebind_thing btt(btr); -- cgit v1.2.3