From 1efcf90a28e1ee24e5ef80fd55bab8b0fccd01df Mon Sep 17 00:00:00 2001 From: Yashas Date: Fri, 29 Sep 2017 16:21:13 +0530 Subject: [PATCH 1/2] new error msg for returning arrays of unknown size --- source/compiler/sc5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/compiler/sc5.c b/source/compiler/sc5.c index 34a1c77..8f81319 100644 --- a/source/compiler/sc5.c +++ b/source/compiler/sc5.c @@ -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[] = { From 00a1cd7e881af617a577d9d6fad8c949d0f8402e Mon Sep 17 00:00:00 2001 From: Yashas Date: Fri, 29 Sep 2017 16:21:33 +0530 Subject: [PATCH 2/2] trigger an error if an array of unknown size is returned --- source/compiler/sc3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/compiler/sc3.c b/source/compiler/sc3.c index d419061..8fe657b 100644 --- a/source/compiler/sc3.c +++ b/source/compiler/sc3.c @@ -1984,7 +1984,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;