aboutsummaryrefslogtreecommitdiff
path: root/Parse/Parser.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-09 17:14:05 +0000
committerChris Lattner <sabre@nondot.org>2007-10-09 17:14:05 +0000
commitb652cea7d7b70ebe3744fb6d72c9ad9cf3c95429 (patch)
tree856f709f139b4b0f692115183c8462bfec20d40c /Parse/Parser.cpp
parent00ee4e4ddc10f30ab2d675752f041c738513a3ce (diff)
rename some "Parse" actions to "ActOn". Move code around in
ParseFunctionDefinition so that ActOnFunctionDefBody is always called if ActOnStartOfFunctionDef is called. This fixes a crash reported by Nuno Lopes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Parse/Parser.cpp')
-rw-r--r--Parse/Parser.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index 362ca35512..abca8a1257 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -457,14 +457,6 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
if (!FTI.hasPrototype && FTI.NumArgs != 0)
ParseKNRParamDeclarations(D);
- // Enter a scope for the function body.
- EnterScope(Scope::FnScope|Scope::DeclScope);
-
- // Tell the actions module that we have entered a function definition with the
- // specified Declarator for the function.
- DeclTy *Res = Actions.ParseStartOfFunctionDef(CurScope, D);
-
-
// We should have an opening brace now.
if (Tok.getKind() != tok::l_brace) {
Diag(Tok, diag::err_expected_fn_body);
@@ -473,26 +465,34 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
SkipUntil(tok::l_brace, true, true);
// If we didn't find the '{', bail out.
- if (Tok.getKind() != tok::l_brace) {
- ExitScope();
+ if (Tok.getKind() != tok::l_brace)
return 0;
- }
}
+ SourceLocation BraceLoc = Tok.getLocation();
+
+ // Enter a scope for the function body.
+ EnterScope(Scope::FnScope|Scope::DeclScope);
+
+ // Tell the actions module that we have entered a function definition with the
+ // specified Declarator for the function.
+ DeclTy *Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
+
+
// 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;
- }
+
+ // If the function body could not be parsed, make a bogus compoundstmt.
+ if (FnBody.isInvalid)
+ FnBody = Actions.ActOnCompoundStmt(BraceLoc, BraceLoc, 0, 0, false);
// Leave the function body scope.
ExitScope();
// TODO: Pass argument information.
- return Actions.ParseFunctionDefBody(Res, FnBody.Val);
+ return Actions.ActOnFunctionDefBody(Res, FnBody.Val);
}
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides