Teach Sema::ActOnCXXNestedNameSpecifier and Sema::CheckTemplateIdType
to cope with non-type templates by providing appropriate
errors. Previously, we would either assert, crash, or silently build a
dependent type when we shouldn't. Fixes PR9226.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127037 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index eef2f5e..d09f20e 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -197,42 +197,37 @@
         return false;
       }
 
-      if (TemplateId->Kind == TNK_Type_template ||
-          TemplateId->Kind == TNK_Dependent_template_name) {
-        // Consume the template-id token.
-        ConsumeToken();
-        
-        assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!");
-        SourceLocation CCLoc = ConsumeToken();
+      // Consume the template-id token.
+      ConsumeToken();
+      
+      assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!");
+      SourceLocation CCLoc = ConsumeToken();
 
-        if (!HasScopeSpecifier)
-          HasScopeSpecifier = true;
-        
-        ASTTemplateArgsPtr TemplateArgsPtr(Actions,
-                                           TemplateId->getTemplateArgs(),
-                                           TemplateId->NumArgs);
-        
-        if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(),
-                                                /*FIXME:*/SourceLocation(),
-                                                SS, 
-                                                TemplateId->Template,
-                                                TemplateId->TemplateNameLoc,
-                                                TemplateId->LAngleLoc,
-                                                TemplateArgsPtr,
-                                                TemplateId->RAngleLoc,
-                                                CCLoc,
-                                                EnteringContext)) {
-          SourceLocation StartLoc 
-            = SS.getBeginLoc().isValid()? SS.getBeginLoc()
-                                        : TemplateId->TemplateNameLoc;
-          SS.SetInvalid(SourceRange(StartLoc, CCLoc));
-        }
-        
-        TemplateId->Destroy();
-        continue;
+      if (!HasScopeSpecifier)
+        HasScopeSpecifier = true;
+      
+      ASTTemplateArgsPtr TemplateArgsPtr(Actions,
+                                         TemplateId->getTemplateArgs(),
+                                         TemplateId->NumArgs);
+      
+      if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(),
+                                              /*FIXME:*/SourceLocation(),
+                                              SS, 
+                                              TemplateId->Template,
+                                              TemplateId->TemplateNameLoc,
+                                              TemplateId->LAngleLoc,
+                                              TemplateArgsPtr,
+                                              TemplateId->RAngleLoc,
+                                              CCLoc,
+                                              EnteringContext)) {
+        SourceLocation StartLoc 
+          = SS.getBeginLoc().isValid()? SS.getBeginLoc()
+                                      : TemplateId->TemplateNameLoc;
+        SS.SetInvalid(SourceRange(StartLoc, CCLoc));
       }
-
-      assert(false && "FIXME: Only type template names supported here");
+      
+      TemplateId->Destroy();
+      continue;
     }