From 2460b0c9414c9bbee036312b3d99f81dd232a6f3 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 20 May 2008 09:10:20 +0000 Subject: [PATCH] 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. llvm-svn: 51311 --- clang/lib/Parse/Parser.cpp | 2 +- clang/test/Parser/traditional_arg_scope.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 clang/test/Parser/traditional_arg_scope.c diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 7e41bcc92e33..936604e870b6 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -511,7 +511,7 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // 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()) { diff --git a/clang/test/Parser/traditional_arg_scope.c b/clang/test/Parser/traditional_arg_scope.c new file mode 100644 index 000000000000..222de863fba0 --- /dev/null +++ b/clang/test/Parser/traditional_arg_scope.c @@ -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}} +