Do not use ParseCompoundStatement to parse the body of a function. This causes

an extra scope stack to be pushed between the function body and arguments, which
causes the parser to incorrectly accept stuff like 'int foo(int A) { int A; }',
which is test/Parser/argument_redef.c.

llvm-svn: 39252
This commit is contained in:
Chris Lattner 2007-01-21 06:56:16 +00:00
parent ac71608b17
commit 7f58c3dfe4
1 changed files with 4 additions and 2 deletions

View File

@ -433,8 +433,10 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
}
}
// Parse the function body as a compound stmt.
StmtResult FnBody = ParseCompoundStatement();
// Do not enter a scope for the brace, as the arguments are in the same scope
// (the function body) as the body itself. Instead, just read the statement
// list and put it into a CompoundStmt for safe keeping.
StmtResult FnBody = ParseCompoundStatementBody();
if (FnBody.isInvalid) {
ExitScope();
return 0;