From: Eli Friedman Date: Tue, 20 May 2008 09:10:20 +0000 (+0000) Subject: Fix the scope of K&R-style argument declarations so that they don't X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e33dd5b5cbaddadd54bebe07c8397844365d885;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51311 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 7e41bcc92e..936604e870 100644 --- a/lib/Parse/Parser.cpp +++ b/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/test/Parser/traditional_arg_scope.c b/test/Parser/traditional_arg_scope.c new file mode 100644 index 0000000000..222de863fb --- /dev/null +++ b/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}} +