all excess initializers (that I can think of) are catched now
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 13 Nov 2001 13:25:43 +0000 (13:25 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 13 Nov 2001 13:25:43 +0000 (13:25 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1579 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c

index e876cc4a662f131b6ec7a48ffdb950adbf1c4cd4..000088b1322df60a3e3aa0b015ffc07e83af7ff2 100644 (file)
@@ -1095,11 +1095,16 @@ gatherAutoInit (symbol * autoChain)
          addSym (SymbolTab, newSym, newSym->rname, 0, 0, 1);
 
          /* now lift the code to main */
-         if (IS_AGGREGATE (sym->type))
+         if (IS_AGGREGATE (sym->type)) {
            work = initAggregates (sym, sym->ival, NULL);
-         else
+         } else {
+           if (getNelements(sym->type, sym->ival)>1) {
+             werror (W_EXCESS_INITIALIZERS, "scalar", 
+                     sym->name, sym->lineDef);
+           }
            work = newNode ('=', newAst_VALUE (symbolVal (newSym)),
                            list2expr (sym->ival));
+         }
 
          setAstLineno (work, sym->lineDef);
 
@@ -1118,6 +1123,10 @@ gatherAutoInit (symbol * autoChain)
          if (IS_AGGREGATE (sym->type)) {
            work = initAggregates (sym, sym->ival, NULL);
          } else {
+           if (getNelements(sym->type, sym->ival)>1) {
+             werror (W_EXCESS_INITIALIZERS, "scalar", 
+                     sym->name, sym->lineDef);
+           }
            work = newNode ('=', newAst_VALUE (symbolVal (sym)),
                            list2expr (sym->ival));
          }
index 4523afe01933164ec9c5fcf3af3476e7d4c8c3f3..e31f98609feab8e26ce0c5ccb21fec47d452dc28 100644 (file)
@@ -260,6 +260,10 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
          if (IS_AGGREGATE (sym->type)) {
            ival = initAggregates (sym, sym->ival, NULL);
          } else {
+           if (getNelements(sym->type, sym->ival)>1) {
+             werror (W_EXCESS_INITIALIZERS, "scalar", 
+                     sym->name, sym->lineDef);
+           }
            ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
                     decorateType (resolveSymbols (list2expr (sym->ival))));
          }
@@ -527,7 +531,7 @@ printIvalType (symbol *sym, sym_link * type, initList * ilist, FILE * oFile)
        if (ilist->type == INIT_DEEP)
                ilist = ilist->init.deep;
 
-       if (sym && ilist->next) {
+       if (!IS_AGGREGATE(sym->type) && getNelements(type, ilist)>1) {
          werror (W_EXCESS_INITIALIZERS, "scalar", sym->name, sym->lineDef);
        }
 
@@ -633,7 +637,7 @@ printIvalStruct (symbol * sym, sym_link * type,
                if (IS_BITFIELD(sflds->type)) {
                        printIvalBitFields(&sflds,&iloop,oFile);
                } else {
-                       printIval (NULL, sflds->type, iloop, oFile);
+                       printIval (sym, sflds->type, iloop, oFile);
                }
        }
        if (iloop) {
@@ -709,7 +713,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
   for (;;)
     {
       size++;
-      printIval (NULL, type->next, iloop, oFile);
+      printIval (sym, type->next, iloop, oFile);
       iloop = (iloop ? iloop->next : NULL);