Fixed bug #493423, allow 0 element arrays in structures but no where else
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 20 Dec 2001 05:48:21 +0000 (05:48 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 20 Dec 2001 05:48:21 +0000 (05:48 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1719 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglue.c
src/SDCCsymt.c

index e100f5bb39ba794a02d58408ec06a94ed234db47..bb4e41b695da5fc509ade3d08e9e0f6fcdf38703 100644 (file)
@@ -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);
-           }
-
+         }
+         
        }
     }
 }
index 5592d4a908e08e45ee7a0067ba0fe432c0de4818..1bc4c61009ae55dc8b74fe129995bf8b985436aa 100644 (file)
@@ -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 */