From: sandeep Date: Thu, 20 Dec 2001 05:48:21 +0000 (+0000) Subject: Fixed bug #493423, allow 0 element arrays in structures but no where else X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=f620f7fdc8f565d4843a1459f4e8f8424e81fbdc;p=fw%2Fsdcc Fixed bug #493423, allow 0 element arrays in structures but no where else git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1719 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCglue.c b/src/SDCCglue.c index e100f5bb..bb4e41b6 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -292,23 +292,26 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) sym->rname, SPEC_ADDR (sym->etype)); } - else - { + else { if (newSym) { - // this has been moved to another segment + // this has been moved to another segment } else { - /* allocate space */ - if (options.debug) { - fprintf (map->oFile, "==.\n"); - } - if (IS_STATIC (sym->etype)) - tfprintf (map->oFile, "!slabeldef\n", sym->rname); - else - tfprintf (map->oFile, "!labeldef\n", sym->rname); - tfprintf (map->oFile, "\t!ds\n", - (unsigned int) getSize (sym->type) & 0xffff); + int size = getSize (sym->type); + if (size==0) { + werror(E_UNKNOWN_SIZE,sym->name); + } + /* allocate space */ + if (options.debug) { + fprintf (map->oFile, "==.\n"); + } + if (IS_STATIC (sym->etype)) + tfprintf (map->oFile, "!slabeldef\n", sym->rname); + else + tfprintf (map->oFile, "!labeldef\n", sym->rname); + tfprintf (map->oFile, "\t!ds\n", + (unsigned int) size & 0xffff); } - } + } } } @@ -1086,18 +1089,22 @@ emitStaticSeg (memmap * map, FILE * out) printIval (sym, sym->type, sym->ival, out); noAlloc--; } - else - { + else { /* allocate space */ + int size = getSize (sym->type); + + if (size==0) { + werror(E_UNKNOWN_SIZE,sym->name); + } fprintf (out, "%s:\n", sym->rname); /* special case for character strings */ if (IS_ARRAY (sym->type) && IS_CHAR (sym->type->next) && SPEC_CVAL (sym->etype).v_char) - printChar (out, - SPEC_CVAL (sym->etype).v_char, - strlen (SPEC_CVAL (sym->etype).v_char) + 1); + printChar (out, + SPEC_CVAL (sym->etype).v_char, + strlen (SPEC_CVAL (sym->etype).v_char) + 1); else - tfprintf (out, "\t!ds\n", (unsigned int) getSize (sym->type) & 0xffff); + tfprintf (out, "\t!ds\n", (unsigned int) size & 0xffff); } } } @@ -1342,16 +1349,20 @@ emitOverlay (FILE * afile) sym->rname, SPEC_ADDR (sym->etype)); } - else - { + else { + int size = getSize(sym->type); + + if (size==0) { + werror(E_UNKNOWN_SIZE,sym->name); + } if (options.debug) - fprintf (afile, "==.\n"); + fprintf (afile, "==.\n"); /* allocate space */ tfprintf (afile, "!labeldef\n", sym->rname); tfprintf (afile, "\t!ds\n", (unsigned int) getSize (sym->type) & 0xffff); - } - + } + } } } diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 5592d4a9..1bc4c610 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -790,8 +790,8 @@ getSize (sym_link * p) if (DCL_ELEM(p)) { return DCL_ELEM (p) * getSize (p->next); } else { - werror (E_INTERNAL_ERROR, __FILE__, __LINE__, - "can not tell the size of an array[]"); + // werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + // "can not tell the size of an array[]"); return 0; } case IPOINTER: @@ -1117,13 +1117,6 @@ compStructSize (int su, structdef * sdef) sum += getSize (loop->type); } -#if 0 // jwk: this is done now in addDecl() - /* if function then do the arguments for it */ - if (funcInChain (loop->type)) { - processFuncArgs (loop); - } -#endif - loop = loop->next; /* if this is not a bitfield but the */