- Fixed: There was no check for accessing an array without filling out all the required dimensions.

SVN r3409 (trunk)
This commit is contained in:
Randy Heit 2012-03-08 23:02:57 +00:00
parent 3386968b3d
commit 6c45d91701
3 changed files with 7 additions and 0 deletions

View file

@ -160,6 +160,7 @@ static struct
{ ERR_MISSING_RBRACKET, "Missing ']'." },
{ ERR_ZERO_DIMENSION, "Arrays cannot have a dimension of zero." },
{ ERR_TOO_MANY_DIM_USED, "%s only has %d dimensions." },
{ ERR_TOO_FEW_DIM_USED, "%s access needs %d more dimensions." },
{ ERR_ARRAY_MAPVAR_ONLY, "Only map variables can be arrays." },
{ ERR_NOT_AN_ARRAY, "%s is not an array." },
{ ERR_MISSING_LBRACE_ARR, "Missing opening '{' in array initializer." },

View file

@ -125,6 +125,7 @@ typedef enum
ERR_MISSING_RBRACKET,
ERR_ZERO_DIMENSION,
ERR_TOO_MANY_DIM_USED,
ERR_TOO_FEW_DIM_USED,
ERR_TOO_MANY_ARRAY_INIT,
ERR_EOF,
ERR_ARRAY_MAPVAR_ONLY,

View file

@ -4034,6 +4034,11 @@ static void ParseArrayIndices(symbolNode_t *sym, int requiredIndices)
TK_TokenMustBe(TK_RBRACKET, ERR_MISSING_RBRACKET);
TK_NextToken();
}
if(i < requiredIndices)
{
ERR_Error(ERR_TOO_FEW_DIM_USED, YES,
sym->name, requiredIndices - i);
}
// if there were unspecified indices, multiply the offset by their sizes [JB]
if(requiredIndices < sym->info.array.ndim - 1)
{