diff --git a/compiler/libpc300/sc1.c b/compiler/libpc300/sc1.c index fc15e124..fdaa1633 100755 --- a/compiler/libpc300/sc1.c +++ b/compiler/libpc300/sc1.c @@ -2202,6 +2202,23 @@ static void initials2(int ident,int tag,cell *size,int dim[],int numdim, eq_match_override = matchtoken('='); } + if (numdim > 2) { + int d, hasEmpty = 0; + for (d = 0; d < numdim; d++) { + if (dim[d] == 0) + hasEmpty++; + } + /* Work around ambug 4977 where indirection vectors are computed wrong. */ + if (hasEmpty && hasEmpty < numdim-1 && dim[numdim-1]) { + error(112); + /* This will assert with something like [2][][256] from a separate bug. + * To prevent this assert, automatically wipe the rest of the dims. + */ + for (d = 0; d < numdim - 1; d++) + dim[d] = 0; + } + } + if (!eq_match_override) { assert(ident!=iARRAY || numdim>0); if (ident==iARRAY && dim[numdim-1]==0) { diff --git a/compiler/libpc300/sc5-in.scp b/compiler/libpc300/sc5-in.scp index 8d840fe5..4f77d962 100644 --- a/compiler/libpc300/sc5-in.scp +++ b/compiler/libpc300/sc5-in.scp @@ -129,6 +129,7 @@ static char *fatalmsg[] = { /*109*/ "invalid path: \"%s\"\n", /*110*/ "assertion failed: %s\n", /*111*/ "user error: %s\n", +/*112*/ "specify either all dimensions or only the last dimension\n" }; static char *warnmsg[] = {