[cfe-commits] r51311 - in /cfe/trunk: lib/Parse/Parser.cpp test/Parser/traditional_arg_scope.c

Eli Friedman eli.friedman at gmail.com
Tue May 20 02:10:20 PDT 2008


Author: efriedma
Date: Tue May 20 04:10:20 2008
New Revision: 51311

URL: http://llvm.org/viewvc/llvm-project?rev=51311&view=rev
Log:
Fix the scope of K&R-style argument declarations so that they don't 
extend beyond the end of the function.

I'm not completely sure this is the right way to fix this bug, so 
someone familiar with the parser should double-check.


Added:
    cfe/trunk/test/Parser/traditional_arg_scope.c
Modified:
    cfe/trunk/lib/Parse/Parser.cpp

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

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue May 20 04:10:20 2008
@@ -511,7 +511,7 @@
 
   // Enter function-declaration scope, limiting any declarators to the
   // function prototype scope, including parameter declarators.
-  EnterScope(Scope::DeclScope);
+  EnterScope(Scope::FnScope|Scope::DeclScope);
 
   // Read all the argument declarations.
   while (isDeclarationSpecifier()) {

Added: cfe/trunk/test/Parser/traditional_arg_scope.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/traditional_arg_scope.c?rev=51311&view=auto

==============================================================================
--- cfe/trunk/test/Parser/traditional_arg_scope.c (added)
+++ cfe/trunk/test/Parser/traditional_arg_scope.c Tue May 20 04:10:20 2008
@@ -0,0 +1,5 @@
+// RUN: clang -fsyntax-only %s -verify
+
+x(a) int a; {return a;}
+y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
+





More information about the cfe-commits mailing list