diff options
author | Momchil Velikov <momchil.velikov@arm.com> | 2017-08-10 15:43:06 +0000 |
---|---|---|
committer | Momchil Velikov <momchil.velikov@arm.com> | 2017-08-10 15:43:06 +0000 |
commit | 57c681f33e56019ab92901e09d7bd26b0ccdffa5 (patch) | |
tree | d04a2d4992b1b8f97d8ac8aa0f7e07df124e5257 /clang/lib/Parse/Parser.cpp | |
parent | c717041e847db8bd7dfee61ee2a00c3653704651 (diff) | |
download | llvm-57c681f33e56019ab92901e09d7bd26b0ccdffa5.zip llvm-57c681f33e56019ab92901e09d7bd26b0ccdffa5.tar.gz llvm-57c681f33e56019ab92901e09d7bd26b0ccdffa5.tar.bz2 |
Place implictly declared functions at block scope
Such implicitly declared functions behave as if the enclosing block
contained the declaration extern int name() (C90, 6.3.3.2 Function calls),
thus their names should have block scope (C90, 6.1.2.1 Scope of identifiers).
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=33224
Differential Revision: https://reviews.llvm.org/D33676
llvm-svn: 310616
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 4aa9a59..51f4957 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1075,8 +1075,9 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, TemplateInfo.Kind == ParsedTemplateInfo::Template && Actions.canDelayFunctionBody(D)) { MultiTemplateParamsArg TemplateParameterLists(*TemplateInfo.TemplateParams); - - ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope); + + ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | + Scope::CompoundStmtScope); Scope *ParentScope = getCurScope()->getParent(); D.setFunctionDefinitionKind(FDK_Definition); @@ -1106,7 +1107,8 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, (Tok.is(tok::l_brace) || Tok.is(tok::kw_try) || Tok.is(tok::colon)) && Actions.CurContext->isTranslationUnit()) { - ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope); + ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | + Scope::CompoundStmtScope); Scope *ParentScope = getCurScope()->getParent(); D.setFunctionDefinitionKind(FDK_Definition); @@ -1124,7 +1126,8 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, } // Enter a scope for the function body. - ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope); + ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | + Scope::CompoundStmtScope); // Tell the actions module that we have entered a function definition with the // specified Declarator for the function. |