From: MaartenBrock Date: Sat, 24 Jun 2006 11:48:29 +0000 (+0000) Subject: * src/SDCCglue.c (initPointer), fixed bug 1496419 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=658b300d2a914babde7a788a2da6ae3736d8f1c3;p=fw%2Fsdcc * src/SDCCglue.c (initPointer), fixed bug 1496419 * support/regression/tests/bug1496419.c: new, added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4246 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 5be8c0eb..4fe5e060 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-16 Maarten Brock + + * src/SDCCglue.c (initPointer), fixed bug 1496419 + * support/regression/tests/bug1496419.c: new, added + 2006-06-21 Jesus Calvino-Fraga * device/include/mcs51/at89c51ed2.h: Fixed bug 1510144 changed @@ -64,14 +69,14 @@ valid char operands, allow signed operands for native code, added division and modulo operator handling * device/lib/pic16/libsdcc/char/divschar.c: divschar returns an int - + As a consequence, onebyte.c (if split into two files) and muldiv.c pass regression tests. 2006-06-17 Frieder Ferlemann * doc/Makefile.in: two runs of makeindex seem needed to get - correct page references in the index of sdccman.pdf + correct page references in the index of sdccman.pdf * doc/sdccman.lyx: mentioned cmon51, added links, small changes 2006-06-17 Borut Razem diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 04f12922..be6d80e7 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -360,22 +360,23 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) sym->rname, equ, SPEC_ADDR (sym->etype)); } - else { - int size = getSize (sym->type) + sym->flexArrayLength; - if (size==0) { - werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name); - } - /* allocate space */ - if (options.debug) { - fprintf (map->oFile, "==.\n"); - } + else + { + int size = getSize (sym->type) + sym->flexArrayLength; + if (size==0) { + werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name); + } + /* allocate space */ + if (options.debug) { + fprintf (map->oFile, "==.\n"); + } if (IS_STATIC (sym->etype) || sym->level) - 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); - } + 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); + } } } @@ -430,7 +431,7 @@ initPointer (initList * ilist, sym_link *toType) if (IS_AST_OP (expr) && expr->opval.op == '&') { /* address of symbol */ if (IS_AST_SYM_VALUE (expr->left)) { - val = copyValue (AST_VALUE (expr->left)); + val = AST_VALUE (expr->left); val->type = newLink (DECLARATOR); if (SPEC_SCLS (expr->left->etype) == S_CODE) { DCL_TYPE (val->type) = CPOINTER; @@ -1252,8 +1253,7 @@ emitStaticSeg (memmap * map, FILE * out) if (IS_EXTERN (sym->etype)) continue; - /* if it is not static add it to the public - table */ + /* if it is not static add it to the public table */ if (!IS_STATIC (sym->etype)) { addSetHead (&publics, sym); @@ -1925,7 +1925,6 @@ glue (void) if (mainf && IFFUNC_HASBODY(mainf->type)) { - /* entry point @ start of HOME */ fprintf (asmFile, "__sdcc_program_startup:\n"); diff --git a/support/regression/tests/bug1496419.c b/support/regression/tests/bug1496419.c new file mode 100644 index 00000000..19268606 --- /dev/null +++ b/support/regression/tests/bug1496419.c @@ -0,0 +1,21 @@ +/* + bug1057979.c +*/ + +#include + +typedef struct _NODE +{ + const struct _NODE * enter; + const struct _NODE * down; +}NODE; + +const NODE node1 = {NULL, NULL}; + +//sdcc loops allocating space for new symbols node1 and +//zzz until there is no more memory, then segfaults +// +//The reference to zzz inside the declaration of zzz +//triggers a loop allocating space for symbols node1 +//and zzz +const NODE zzz = {&node1, &zzz};