[cfe-commits] r90986 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseDeclCXX.cpp lib/Parse/Parser.cpp test/Parser/cxx-extern-c-array.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Dec 9 13:39:38 PST 2009


Author: fjahanian
Date: Wed Dec  9 15:39:38 2009
New Revision: 90986

URL: http://llvm.org/viewvc/llvm-project?rev=90986&view=rev
Log:
Fixes a bogus error when declaring an extern "C" array.
(fixes radar 7457109).

Added:
    cfe/trunk/test/Parser/cxx-extern-c-array.cpp
Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=90986&r1=90985&r2=90986&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Dec  9 15:39:38 2009
@@ -759,7 +759,10 @@
   bool isStartOfFunctionDefinition();
   DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
             AccessSpecifier AS = AS_none);
-
+  DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(ParsingDeclSpec &DS,
+                                                  AttributeList *Attr,
+                                                  AccessSpecifier AS = AS_none);
+  
   DeclPtrTy ParseFunctionDefinition(ParsingDeclarator &D,
                  const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
   void ParseKNRParamDeclarations(Declarator &D);
@@ -1290,7 +1293,7 @@
                                  tok::TokenKind *After = 0);
   
   DeclPtrTy ParseNamespace(unsigned Context, SourceLocation &DeclEnd);
-  DeclPtrTy ParseLinkage(unsigned Context);
+  DeclPtrTy ParseLinkage(ParsingDeclSpec &DS, unsigned Context);
   DeclPtrTy ParseUsingDirectiveOrDeclaration(unsigned Context,
                                              SourceLocation &DeclEnd,
                                              CXX0XAttributeList Attrs);

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=90986&r1=90985&r2=90986&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Dec  9 15:39:38 2009
@@ -161,7 +161,8 @@
 ///         'extern' string-literal '{' declaration-seq[opt] '}'
 ///         'extern' string-literal declaration
 ///
-Parser::DeclPtrTy Parser::ParseLinkage(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseLinkage(ParsingDeclSpec &DS,
+                                       unsigned Context) {
   assert(Tok.is(tok::string_literal) && "Not a string literal!");
   llvm::SmallVector<char, 8> LangBuffer;
   // LangBuffer is guaranteed to be big enough.
@@ -185,7 +186,7 @@
   }
   
   if (Tok.isNot(tok::l_brace)) {
-    ParseDeclarationOrFunctionDefinition(Attr.AttrList);
+    ParseDeclarationOrFunctionDefinition(DS, Attr.AttrList);
     return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec,
                                                    SourceLocation());
   }

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=90986&r1=90985&r2=90986&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Dec  9 15:39:38 2009
@@ -533,10 +533,10 @@
 /// [OMP]   threadprivate-directive                              [TODO]
 ///
 Parser::DeclGroupPtrTy
-Parser::ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
+Parser::ParseDeclarationOrFunctionDefinition(ParsingDeclSpec &DS,
+                                             AttributeList *Attr,
                                              AccessSpecifier AS) {
   // Parse the common declaration-specifiers piece.
-  ParsingDeclSpec DS(*this);
   if (Attr)
     DS.AddAttributes(Attr);
 
@@ -585,13 +585,20 @@
       DS.getStorageClassSpec() == DeclSpec::SCS_extern &&
       DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier) {
     DS.abort();
-    DeclPtrTy TheDecl = ParseLinkage(Declarator::FileContext);
+    DeclPtrTy TheDecl = ParseLinkage(DS, Declarator::FileContext);
     return Actions.ConvertDeclToDeclGroup(TheDecl);
   }
 
   return ParseDeclGroup(DS, Declarator::FileContext, true);
 }
 
+Parser::DeclGroupPtrTy
+Parser::ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
+                                             AccessSpecifier AS) {
+  ParsingDeclSpec DS(*this);
+  return ParseDeclarationOrFunctionDefinition(DS, Attr, AS);
+}
+
 /// ParseFunctionDefinition - We parsed and verified that the specified
 /// Declarator is well formed.  If this is a K&R-style function, read the
 /// parameters declaration-list, then start the compound-statement.

Added: cfe/trunk/test/Parser/cxx-extern-c-array.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-extern-c-array.cpp?rev=90986&view=auto

==============================================================================
--- cfe/trunk/test/Parser/cxx-extern-c-array.cpp (added)
+++ cfe/trunk/test/Parser/cxx-extern-c-array.cpp Wed Dec  9 15:39:38 2009
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+extern "C" int myarray[];
+int myarray[12] = {0};
+
+extern "C" int anotherarray[][3];
+int anotherarray[2][3] = {1,2,3,4,5,6};





More information about the cfe-commits mailing list