Ultrasimplistic sketch for the parsing of C++ template-ids. This won't
become useful or correct until we (1) parse template arguments
correctly, (2) have some way to turn template-ids into types,
declarators, etc., and (3) have a real representation of templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61208 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 407aa9c..16e7e77 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1452,13 +1452,27 @@
 
       if (Tok.is(tok::identifier)) {
         assert(Tok.getIdentifierInfo() && "Not an identifier?");
-        // Determine whether this identifier is a C++ constructor name or
-        // a normal identifier.
-        if (Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope)) {
+
+        // If this identifier is followed by a '<', we may have a template-id.
+        DeclTy *Template;
+        if (getLang().CPlusPlus && NextToken().is(tok::less) &&
+            (Template = Actions.isTemplateName(*Tok.getIdentifierInfo(), 
+                                               CurScope))) {
+          IdentifierInfo *II = Tok.getIdentifierInfo();
+          AnnotateTemplateIdToken(Template, 0);
+          // FIXME: Set the declarator to a template-id. How? I don't
+          // know... for now, just use the identifier.
+          D.SetIdentifier(II, Tok.getLocation());
+        }
+        // If this identifier is the name of the current class, it's a
+        // constructor name. 
+        else if (getLang().CPlusPlus &&
+                 Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope))
           D.setConstructor(Actions.isTypeName(*Tok.getIdentifierInfo(),
                                               CurScope),
                            Tok.getLocation());
-        } else
+        // This is a normal identifier.
+        else
           D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
         ConsumeToken();
         goto PastIdentifier;