]> granicus.if.org Git - clang/commitdiff
Fix PR9902: correctly substitute alias templates within the template in which they...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 May 2011 00:06:17 +0000 (00:06 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 May 2011 00:06:17 +0000 (00:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131211 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaCXX/PR9902.cpp [new file with mode: 0644]

index a9b8af28c7c775bd89f747133e29bbd3052bf19d..5d93067a95986b08b66fda0c9d42968a1e1cc1d7 100644 (file)
@@ -1855,6 +1855,9 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 
     // Only substitute for the innermost template argument list.
     MultiLevelTemplateArgumentList TemplateArgLists;
+    unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
+    for (unsigned I = 0; I < Depth; ++I)
+      TemplateArgLists.addOuterTemplateArguments(0, 0);
     TemplateArgLists.addOuterTemplateArguments(&TemplateArgs);
 
     InstantiatingTemplate Inst(*this, TemplateLoc, Template);
diff --git a/test/SemaCXX/PR9902.cpp b/test/SemaCXX/PR9902.cpp
new file mode 100644 (file)
index 0000000..ec76789
--- /dev/null
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template <class _Tp, class _Up, bool = false>
+struct __allocator_traits_rebind
+{
+};
+
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args,
+class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
+{
+   typedef _Alloc<_Up, _Args...> type;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+   template <class T> using rebind_alloc = typename __allocator_traits_rebind<Alloc, T>::type;
+   template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+};
+
+template <class T>
+struct allocator {};
+
+int main()
+{
+   allocator_traits<allocator<char>>::rebind_alloc<int> a;
+}