Parsing and AST representation for dependent template names that occur
within nested-name-specifiers, e.g., for the "apply" in

  typename MetaFun::template apply<T1, T2>::type

At present, we can't instantiate these nested-name-specifiers, so our
testing is sketchy.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68081 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 8eda694..45d148e 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -531,8 +531,7 @@
     return; 
 
   // Build the annotation token.
-  // FIXME: Not just for class templates!
-  if (TNK == TNK_Class_template && AllowTypeAnnotation) {
+  if (TNK == TNK_Type_template && AllowTypeAnnotation) {
     Action::TypeResult Type 
       = Actions.ActOnTemplateIdType(Template, TemplateNameLoc,
                                     LAngleLoc, TemplateArgsPtr,
@@ -550,8 +549,8 @@
     else 
       Tok.setLocation(TemplateNameLoc);
   } else {
-    // This is a function template. We'll be building a template-id
-    // annotation token.
+    // Build a template-id annotation token that can be processed
+    // later.
     Tok.setKind(tok::annot_template_id);
     TemplateIdAnnotation *TemplateId 
       = TemplateIdAnnotation::Allocate(TemplateArgs.size());
@@ -595,8 +594,9 @@
 
   TemplateIdAnnotation *TemplateId 
     = static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
-  assert(TemplateId->Kind == TNK_Class_template &&
-         "Only works for class templates");
+  assert((TemplateId->Kind == TNK_Type_template ||
+          TemplateId->Kind == TNK_Dependent_template_name) &&
+         "Only works for type and dependent templates");
   
   ASTTemplateArgsPtr TemplateArgsPtr(Actions, 
                                      TemplateId->getTemplateArgs(),