- Assign the fileDepth of a constant earlier to avoid uninitialized value when evaluating constant.

This commit is contained in:
Braden Obrzut 2015-03-26 17:20:34 -04:00
parent 7a07de833a
commit 918a247c0d

11
parse.c
View file

@ -1190,11 +1190,6 @@ static void OuterDefine(boolean force)
force ? "(forced) " : "");
TK_NextTokenMustBe(TK_IDENTIFIER, ERR_INVALID_IDENTIFIER);
sym = SY_InsertGlobalUnique(tk_String, SY_CONSTANT);
TK_NextToken();
value = EvalConstExpression();
MS_Message(MSG_DEBUG, "Constant value: %d\n", value);
sym->info.constant.value = value;
sym->info.constant.strValue = pa_ConstExprIsString ? strdup(STR_Get(value)) : NULL;
// Defines inside an import are deleted when the import is popped.
if(ImportMode != IMPORT_Importing || force)
{
@ -1204,6 +1199,12 @@ static void OuterDefine(boolean force)
{
sym->info.constant.fileDepth = TK_GetDepth();
}
TK_NextToken();
value = EvalConstExpression();
MS_Message(MSG_DEBUG, "Constant value: %d\n", value);
sym->info.constant.value = value;
sym->info.constant.strValue = pa_ConstExprIsString ? strdup(STR_Get(value)) : NULL;
}
//==========================================================================