Fix for function return value speculation

- a speculated function is now marked as returning a value if it is called as such at any point before its definition
- no unwarranted errors about missing return values are raised for speculated functions anymore
This commit is contained in:
rhinoduck 2014-03-31 18:28:31 +02:00 committed by Randy Heit
parent 70fe03f7d4
commit 701c391c3f

View file

@ -2103,6 +2103,10 @@ static void ProcessScriptFunc(symbolNode_t *sym, boolean discardReturn)
int argCount; int argCount;
MS_Message(MSG_DEBUG, "---- ProcessScriptFunc ----\n"); MS_Message(MSG_DEBUG, "---- ProcessScriptFunc ----\n");
if(sym->info.scriptFunc.predefined == YES && discardReturn == NO)
{
sym->info.scriptFunc.hasReturnValue = YES;
}
argCount = sym->info.scriptFunc.argCount; argCount = sym->info.scriptFunc.argCount;
TK_NextTokenMustBe(TK_LPAREN, ERR_MISSING_LPAREN); TK_NextTokenMustBe(TK_LPAREN, ERR_MISSING_LPAREN);
i = 0; i = 0;
@ -3694,7 +3698,8 @@ static void ExprFactor(void)
ProcessInternFunc(sym); ProcessInternFunc(sym);
break; break;
case SY_SCRIPTFUNC: case SY_SCRIPTFUNC:
if(sym->info.scriptFunc.hasReturnValue == NO) if(sym->info.scriptFunc.predefined == NO
&& sym->info.scriptFunc.hasReturnValue == NO)
{ {
ERR_Error(ERR_EXPR_FUNC_NO_RET_VAL, YES); ERR_Error(ERR_EXPR_FUNC_NO_RET_VAL, YES);
} }