From: Eli Friedman Date: Fri, 29 May 2009 01:49:24 +0000 (+0000) Subject: If a declarator group declares a type, make sure to add that declaration X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1dc653b08226c1d8e1732f9d8b03b82869900bc;p=clang If a declarator group declares a type, make sure to add that declaration to the DeclGroup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72559 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 86e3194836..328de90036 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -291,7 +291,8 @@ public: /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this /// gives the actions implementation a chance to process the group as a whole. - virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group, + virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS, + DeclPtrTy *Group, unsigned NumDecls) { return DeclGroupPtrTy(); } diff --git a/lib/Frontend/PrintParserCallbacks.cpp b/lib/Frontend/PrintParserCallbacks.cpp index 73530ef58d..ca13f3df29 100644 --- a/lib/Frontend/PrintParserCallbacks.cpp +++ b/lib/Frontend/PrintParserCallbacks.cpp @@ -116,7 +116,8 @@ namespace { /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, /// this gives the actions implementation a chance to process the group as /// a whole. - virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group, + virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS, + DeclPtrTy *Group, unsigned NumDecls) { Out << __FUNCTION__ << "\n"; return DeclGroupPtrTy(); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 54e70be16e..b667014efc 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -437,7 +437,8 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) { ParseDeclarator(D); } - return Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(), + return Actions.FinalizeDeclaratorGroup(CurScope, D.getDeclSpec(), + DeclsInGroup.data(), DeclsInGroup.size()); } diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index cfbd9097f7..7cbd72bed4 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -970,7 +970,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) { if (Tok.is(tok::semi)) { ConsumeToken(); - Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(), + Actions.FinalizeDeclaratorGroup(CurScope, DS, DeclsInGroup.data(), DeclsInGroup.size()); return; } diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index fae5a92747..75632d560e 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -410,7 +410,8 @@ public: void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit); void ActOnUninitializedDecl(DeclPtrTy dcl); virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc); - virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group, + virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, + DeclPtrTy *Group, unsigned NumDecls); virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6a2e3099cd..8bd753abea 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2754,10 +2754,14 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) { } } -Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group, +Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, + DeclPtrTy *Group, unsigned NumDecls) { llvm::SmallVector Decls; - + + if (DS.isTypeSpecOwned()) + Decls.push_back((Decl*)DS.getTypeRep()); + for (unsigned i = 0; i != NumDecls; ++i) if (Decl *D = Group[i].getAs()) Decls.push_back(D);