Fix function return source position with implicit return
This commit is contained in:
parent
d6faefb5fc
commit
9175257bbc
|
@ -92,7 +92,7 @@ void DeclarationScope::End(const Location& loc)
|
|||
}
|
||||
|
||||
Expression::Expression(const Location& loc, ExpressionType type)
|
||||
: mLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false)
|
||||
: mLocation(loc), mEndLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public:
|
|||
Expression(const Location& loc, ExpressionType type);
|
||||
~Expression(void);
|
||||
|
||||
Location mLocation;
|
||||
Location mLocation, mEndLocation;
|
||||
ExpressionType mType;
|
||||
Expression * mLeft, * mRight;
|
||||
Token mToken;
|
||||
|
|
|
@ -3798,7 +3798,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
|||
else
|
||||
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mIdent->mString);
|
||||
|
||||
InterInstruction * ins = new InterInstruction(exp ? exp->mLocation : dec->mLocation, IC_RETURN);
|
||||
InterInstruction * ins = new InterInstruction(exp ? exp->mEndLocation : dec->mLocation, IC_RETURN);
|
||||
exitBlock->Append(ins);
|
||||
exitBlock->Close(nullptr, nullptr);
|
||||
|
||||
|
|
|
@ -2185,12 +2185,14 @@ Expression* Parser::ParseStatement(void)
|
|||
if (mScanner->mToken != TK_CLOSE_BRACE)
|
||||
mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "'}' expected");
|
||||
|
||||
exp->mEndLocation = mScanner->mLocation;
|
||||
mScope->End(mScanner->mLocation);
|
||||
mScanner->NextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
exp = new Expression(mScanner->mLocation, EX_VOID);
|
||||
exp->mEndLocation = mScanner->mLocation;
|
||||
mScanner->NextToken();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue