Bug 737, crash parsing default args.

Reject function evaluation explicitly when building
default arguments.
This commit is contained in:
James Turner 2013-07-23 09:43:08 +01:00
parent b236821661
commit 3cb2241b1d

View File

@ -147,7 +147,15 @@ static void genEqOp(int op, struct Parser* p, struct Token* t)
static int defArg(struct Parser* p, struct Token* t)
{
if(t->type == TOK_LPAR) return defArg(p, RIGHT(t));
if(t->type == TOK_LPAR) {
// http://code.google.com/p/flightgear-bugs/issues/detail?id=737
// TOK_LPAR can mean multi-value assignment or function call,
// disambigaute by checking the rule of the token
if (t->rule == PREC_SUFFIX)
naParseError(p, "default arguments cannot be function calls", t->line);
return defArg(p, RIGHT(t));
}
if(t->type == TOK_MINUS && RIGHT(t) &&
RIGHT(t)->type == TOK_LITERAL && !RIGHT(t)->str)
{