Parse extern templates, pass that information all the way to Sema,
then drop it on the floor.

llvm-svn: 80989
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 385b805..c82f6a4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -638,6 +638,7 @@
       // This is an explicit instantiation of a class template.
       TagOrTempResult
         = Actions.ActOnExplicitInstantiation(CurScope, 
+                                             TemplateInfo.ExternLoc,
                                              TemplateInfo.TemplateLoc, 
                                              TagType,
                                              StartLoc, 
@@ -734,6 +735,7 @@
     //
     TagOrTempResult
       = Actions.ActOnExplicitInstantiation(CurScope, 
+                                           TemplateInfo.ExternLoc,
                                            TemplateInfo.TemplateLoc, 
                                            TagType, StartLoc, SS, Name, 
                                            NameLoc, Attr);
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index 34cabfd..40de81a 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -25,7 +25,8 @@
                                              SourceLocation &DeclEnd,
                                              AccessSpecifier AS) {
   if (Tok.is(tok::kw_template) && NextToken().isNot(tok::less))
-    return ParseExplicitInstantiation(ConsumeToken(), DeclEnd);
+    return ParseExplicitInstantiation(SourceLocation(), ConsumeToken(), 
+                                      DeclEnd);
 
   return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AS);
 }
@@ -186,7 +187,6 @@
   
   // Parse the declaration specifiers.
   DeclSpec DS;
-  // FIXME: Pass TemplateLoc through for explicit template instantiations
   ParseDeclarationSpecifiers(DS, TemplateInfo, AS);
 
   if (Tok.is(tok::semi)) {
@@ -871,11 +871,15 @@
 /// (C++ [temp.explicit]).
 ///
 ///       explicit-instantiation:
-///         'template' declaration
+///         'extern' [opt] 'template' declaration
+///
+/// Note that the 'extern' is a GNU extension and C++0x feature.
 Parser::DeclPtrTy 
-Parser::ParseExplicitInstantiation(SourceLocation TemplateLoc,
+Parser::ParseExplicitInstantiation(SourceLocation ExternLoc,
+                                   SourceLocation TemplateLoc,
                                    SourceLocation &DeclEnd) {
   return ParseSingleDeclarationAfterTemplate(Declarator::FileContext, 
-                                             ParsedTemplateInfo(TemplateLoc),
+                                             ParsedTemplateInfo(ExternLoc,
+                                                                TemplateLoc),
                                              DeclEnd, AS_none);
 }
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 36d5db5..8572d32 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -391,6 +391,7 @@
 /// [C++0x] empty-declaration:
 ///           ';'
 ///
+/// [C++0x/GNU] 'extern' 'template' declaration
 Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration() {
   DeclPtrTy SingleDecl;
   switch (Tok.getKind()) {
@@ -452,6 +453,20 @@
       SourceLocation DeclEnd;
       return ParseDeclaration(Declarator::FileContext, DeclEnd);
     }
+  case tok::kw_extern:
+    if (getLang().CPlusPlus && NextToken().is(tok::kw_template)) {
+      // Extern templates
+      SourceLocation ExternLoc = ConsumeToken();
+      SourceLocation TemplateLoc = ConsumeToken();
+      SourceLocation DeclEnd;
+      return Actions.ConvertDeclToDeclGroup(
+                  ParseExplicitInstantiation(ExternLoc, TemplateLoc, DeclEnd));
+    }
+    
+    // FIXME: Detect C++ linkage specifications here?
+      
+    // Fall through to handle other declarations or function definitions.
+      
   default:
     // We can't tell whether this is a function-definition or declaration yet.
     return ParseDeclarationOrFunctionDefinition();