* src/SDCCglue.c (initPointer), fixed bug 1496419
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 24 Jun 2006 11:48:29 +0000 (11:48 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 24 Jun 2006 11:48:29 +0000 (11:48 +0000)
* 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

ChangeLog
src/SDCCglue.c
support/regression/tests/bug1496419.c [new file with mode: 0644]

index 5be8c0ebd2a706d794d66cdeff2f1667c335adcd..4fe5e06011b0b465307a9db7eeafb3637cc01cb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-16 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCglue.c (initPointer), fixed bug 1496419
+       * support/regression/tests/bug1496419.c: new, added
+
 2006-06-21 Jesus Calvino-Fraga <jesusc at ece.ubc.ca>
 
        * device/include/mcs51/at89c51ed2.h: Fixed bug 1510144 changed
            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 <Frieder.Ferlemann AT web.de>
 
        * 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 <borut.razem AT siol.net>
index 04f12922f7a1e38d00106fbad5989685acf1065a..be6d80e76d1bda3ecf1403788b99c12efdc5e01d 100644 (file)
@@ -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 (file)
index 0000000..1926860
--- /dev/null
@@ -0,0 +1,21 @@
+/*\r
+   bug1057979.c\r
+*/\r
+\r
+#include <testfwk.h>\r
+\r
+typedef struct _NODE\r
+{\r
+  const struct _NODE * enter;\r
+  const struct _NODE * down;\r
+}NODE;\r
+\r
+const NODE node1 = {NULL, NULL};\r
+\r
+//sdcc loops allocating space for new symbols node1 and\r
+//zzz until there is no more memory, then segfaults\r
+//\r
+//The reference to zzz inside the declaration of zzz\r
+//triggers a loop allocating space for symbols node1\r
+//and zzz\r
+const NODE zzz = {&node1, &zzz};\r