Compiler: Fix an issue related to passing arrays based on an enumeration to a function (#582)

This commit is contained in:
Vincent Herbet 2018-09-14 15:47:11 +02:00 committed by GitHub
parent 8f88dc5ac8
commit 5694acf482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2058,7 +2058,8 @@ static int nesting=0;
error(35,argidx+1); /* argument type mismatch */
/* Verify that the dimensions match with those in arg[argidx].
* A literal array always has a single dimension.
* An iARRAYCELL parameter is also assumed to have a single dimension.
* An iARRAYCELL parameter is also assumed to have a single dimension,
* but its size may be >1 in case of an enumeration pseudo-array.
*/
if (lval.sym==NULL || lval.ident==iARRAYCELL) {
if (arg[argidx].numdim!=1) {
@ -2066,7 +2067,8 @@ static int nesting=0;
} else if (arg[argidx].dim[0]!=0) {
assert(arg[argidx].dim[0]>0);
if (lval.ident==iARRAYCELL) {
error(47); /* array sizes must match */
if (lval.constval==0 || arg[argidx].dim[0]!=lval.constval)
error(47); /* array sizes must match */
} else {
assert(lval.constval!=0); /* literal array must have a size */
/* A literal array must have exactly the same size as the