From 7f58c3dfe46400bd6e07b1f8a57048410e8dcfe3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 21 Jan 2007 06:56:16 +0000 Subject: [PATCH] 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 --- clang/Parse/Parser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/Parse/Parser.cpp b/clang/Parse/Parser.cpp index 02dca878759f..cf440cfdb647 100644 --- a/clang/Parse/Parser.cpp +++ b/clang/Parse/Parser.cpp @@ -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;