Merge pull request #190 from YashasSamaga/i154-fix

trigger error if an array of unknown size is being returned
This commit is contained in:
Zeex 2017-10-08 02:48:48 +06:00 committed by GitHub
commit 2a85a9fa33
2 changed files with 5 additions and 2 deletions

View File

@ -2016,7 +2016,9 @@ static int nesting=0;
* reserved memory block as a hidden parameter
*/
retsize=(int)array_totalsize(symret);
assert(retsize>0);
if (retsize<=0) {
error(92,sym->name);
} /* if */
modheap(retsize*sizeof(cell));/* address is in ALT */
pushreg(sALT); /* pass ALT as the last (hidden) parameter */
decl_heap+=retsize;

View File

@ -128,7 +128,8 @@ static char *errmsg[] = {
/*088*/ "public variables and local variables may not have states (symbol \"%s\")\n",
/*089*/ "state variables may not be initialized (symbol \"%s\")\n",
/*090*/ "public functions may not return arrays (symbol \"%s\")\n",
/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n"
/*091*/ "ambiguous constant; tag override is required (symbol \"%s\")\n",
/*092*/ "functions may not return arrays of unknown size (symbol \"%s\")\n"
};
static char *fatalmsg[] = {