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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131342 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 58c12d4..c31ed01 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1859,10 +1859,10 @@
 
     // Only substitute for the innermost template argument list.
     MultiLevelTemplateArgumentList TemplateArgLists;
+    TemplateArgLists.addOuterTemplateArguments(&TemplateArgs);
     unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
     for (unsigned I = 0; I < Depth; ++I)
       TemplateArgLists.addOuterTemplateArguments(0, 0);
-    TemplateArgLists.addOuterTemplateArguments(&TemplateArgs);
 
     InstantiatingTemplate Inst(*this, TemplateLoc, Template);
     CanonType = SubstType(Pattern->getUnderlyingType(),