diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-08 04:40:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-08 04:40:51 +0000 |
commit | aa9c7aed0fd2cc29afae9875bab70d1c25345625 (patch) | |
tree | 4402f923c782e1acf48aea09d8098226bb2af5ef /clang/lib/Parse/Parser.cpp | |
parent | 2163265b533250ffa695fbfaa4d3a34f3b07a7b5 (diff) | |
download | bcm5719-llvm-aa9c7aed0fd2cc29afae9875bab70d1c25345625.tar.gz bcm5719-llvm-aa9c7aed0fd2cc29afae9875bab70d1c25345625.zip |
Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.
Patch by Doug Gregor!
llvm-svn: 49369
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index cd99fc04ebe..7e41bcc92e3 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -509,6 +509,10 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // We know that the top-level of this declarator is a function. DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun; + // Enter function-declaration scope, limiting any declarators to the + // function prototype scope, including parameter declarators. + EnterScope(Scope::DeclScope); + // Read all the argument declarations. while (isDeclarationSpecifier()) { SourceLocation DSStart = Tok.getLocation(); @@ -555,10 +559,10 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { AttrList = ParseAttributes(); // Ask the actions module to compute the type for this declarator. - Action::TypeResult TR = - Actions.ActOnParamDeclaratorType(CurScope, ParmDeclarator); + Action::DeclTy *Param = + Actions.ActOnParamDeclarator(CurScope, ParmDeclarator); - if (!TR.isInvalid && + if (Param && // A missing identifier has already been diagnosed. ParmDeclarator.getIdentifier()) { @@ -575,12 +579,12 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { if (FTI.ArgInfo[i].Ident == ParmDeclarator.getIdentifier()) { // Reject redefinitions of parameters. - if (FTI.ArgInfo[i].TypeInfo) { + if (FTI.ArgInfo[i].Param) { Diag(ParmDeclarator.getIdentifierLoc(), diag::err_param_redefinition, ParmDeclarator.getIdentifier()->getName()); } else { - FTI.ArgInfo[i].TypeInfo = TR.Val; + FTI.ArgInfo[i].Param = Param; } break; } @@ -611,6 +615,9 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { } } + // Leave prototype scope. + ExitScope(); + // The actions module must verify that all arguments were declared. } |