[cfe-commits] r39252 - /cfe/cfe/trunk/Parse/Parser.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:41:58 PDT 2007


Author: sabre
Date: Wed Jul 11 11:41:57 2007
New Revision: 39252

URL: http://llvm.org/viewvc/llvm-project?rev=39252&view=rev
Log:
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.

Modified:
    cfe/cfe/trunk/Parse/Parser.cpp

Modified: cfe/cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/Parser.cpp?rev=39252&r1=39251&r2=39252&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/cfe/trunk/Parse/Parser.cpp Wed Jul 11 11:41:57 2007
@@ -433,8 +433,10 @@
     }
   }
   
-  // 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;





More information about the cfe-commits mailing list