]> granicus.if.org Git - clang/commitdiff
Parse all kinds of declarations as part of a linkage-specification,
authorDouglas Gregor <dgregor@apple.com>
Tue, 24 Aug 2010 14:14:45 +0000 (14:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 24 Aug 2010 14:14:45 +0000 (14:14 +0000)
from Francois Pichet! Fixes PR7754.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111912 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Parser.h
lib/Parse/ParseDeclCXX.cpp
lib/Parse/Parser.cpp
test/SemaCXX/linkage-spec.cpp

index cc82c0b0a560c6552b90c7cec13a16bf46948630..ceaeb34ee584166c0db3fd94412c123d916b669d 100644 (file)
@@ -859,7 +859,8 @@ private:
 
   //===--------------------------------------------------------------------===//
   // C99 6.9: External Definitions.
-  DeclGroupPtrTy ParseExternalDeclaration(CXX0XAttributeList Attr);
+  DeclGroupPtrTy ParseExternalDeclaration(CXX0XAttributeList Attr,
+                                          ParsingDeclSpec *DS = 0);
   bool isDeclarationAfterDeclarator() const;
   bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator);
   DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
index e412f25dbba22b1abb2d0939538831193cb7aa10..d80410c9ee55c4eccb2d35c8f6b79c32da3ec219 100644 (file)
@@ -197,7 +197,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS,
 
   if (Tok.isNot(tok::l_brace)) {
     DS.setExternInLinkageSpec(true);
-    ParseDeclarationOrFunctionDefinition(DS, Attr.AttrList);
+    ParseExternalDeclaration(Attr, &DS);
     return Actions.ActOnFinishLinkageSpecification(getCurScope(), LinkageSpec,
                                                    SourceLocation());
   }
index 2f5070c4c39a0ae62f23248659a947652c6e4229..8fd1e48994485c692468376532bce826893cffe9 100644 (file)
@@ -405,7 +405,8 @@ void Parser::ParseTranslationUnit() {
 ///           ';'
 ///
 /// [C++0x/GNU] 'extern' 'template' declaration
-Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr) {
+Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr,
+                                                        ParsingDeclSpec *DS) {
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
   
   Decl *SingleDecl = 0;
@@ -494,7 +495,10 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr)
 
   default:
     // We can't tell whether this is a function-definition or declaration yet.
-    return ParseDeclarationOrFunctionDefinition(Attr.AttrList);
+    if (DS)
+      return ParseDeclarationOrFunctionDefinition(*DS, Attr.AttrList);
+    else
+      return ParseDeclarationOrFunctionDefinition(Attr.AttrList);
   }
 
   // This routine returns a DeclGroup, if the thing we parsed only contains a
index b2e8eb2ee8bb5c712d1f50585661fa4ebef8c036..86c3d3e87a4cc2351c66debadc2e11876e1d0534 100644 (file)
@@ -77,3 +77,12 @@ extern "C" {
     s0(const s0 &);
   };
 }
+
+//PR7754
+extern "C++" template <class T> int pr7754(T param);
+
+namespace N {
+  int value;
+}
+
+extern "C++" using N::value;