diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-09 21:39:38 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-09 21:39:38 +0000 |
commit | 3acd9aaa4ddd14afecb4f1c02ca6f585a6d51849 (patch) | |
tree | d1d308e96238e9f98c2d23c7196d4deb68c07cba | |
parent | 39406b1395f69341c045e863a6620310abdc55b6 (diff) |
Fixes a bogus error when declaring an extern "C" array.
(fixes radar 7457109).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90986 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Parser.h | 7 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 5 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 13 | ||||
-rw-r--r-- | test/Parser/cxx-extern-c-array.cpp | 7 |
4 files changed, 25 insertions, 7 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 3814cb9cc1..c6dad07aaa 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -759,7 +759,10 @@ private: 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 @@ private: 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); diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 3a3f38e7c2..b52065f3d0 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -161,7 +161,8 @@ Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc, /// '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 @@ Parser::DeclPtrTy Parser::ParseLinkage(unsigned Context) { } if (Tok.isNot(tok::l_brace)) { - ParseDeclarationOrFunctionDefinition(Attr.AttrList); + ParseDeclarationOrFunctionDefinition(DS, Attr.AttrList); return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec, SourceLocation()); } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 20e5c589d7..b6e566518f 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -533,10 +533,10 @@ bool Parser::isStartOfFunctionDefinition() { /// [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 @@ Parser::ParseDeclarationOrFunctionDefinition(AttributeList *Attr, 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. diff --git a/test/Parser/cxx-extern-c-array.cpp b/test/Parser/cxx-extern-c-array.cpp new file mode 100644 index 0000000000..1a04fa05c2 --- /dev/null +++ b/test/Parser/cxx-extern-c-array.cpp @@ -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}; |