fixed bug #478037
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 12 Nov 2001 17:14:17 +0000 (17:14 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 12 Nov 2001 17:14:17 +0000 (17:14 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1576 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c

index f04159bf769a4457798c72c09477863d213ba711..5d17fab58fd8261108bbe37c390853216d749044 100644 (file)
@@ -861,7 +861,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist)
            char *name=sym->opval.val->sym->name;
            int lineno=sym->opval.val->sym->lineDef;
            
-           werror (W_EXESS_ARRAY_INITIALIZERS, name, lineno);
+           werror (W_EXCESS_INITIALIZERS, "array", name, lineno);
        }
     }
     else
@@ -886,7 +886,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist)
                // there has to be a better way
                char *name=sym->opval.val->sym->name;
                int lineno=sym->opval.val->sym->lineDef;
-               werror (W_EXESS_ARRAY_INITIALIZERS, name, lineno);
+               werror (W_EXCESS_INITIALIZERS, "array", name, lineno);
                
                break;
            }
index 55487f379a1f6eb8939a46db25137c7f9423230a..4523afe01933164ec9c5fcf3af3476e7d4c8c3f3 100644 (file)
@@ -519,7 +519,7 @@ printGPointerType (FILE * oFile, const char *iname, const char *oname,
 /* printIvalType - generates ival for int/char                     */
 /*-----------------------------------------------------------------*/
 void 
-printIvalType (sym_link * type, initList * ilist, FILE * oFile)
+printIvalType (symbol *sym, sym_link * type, initList * ilist, FILE * oFile)
 {
        value *val;
 
@@ -527,6 +527,10 @@ printIvalType (sym_link * type, initList * ilist, FILE * oFile)
        if (ilist->type == INIT_DEEP)
                ilist = ilist->init.deep;
 
+       if (sym && ilist->next) {
+         werror (W_EXCESS_INITIALIZERS, "scalar", sym->name, sym->lineDef);
+       }
+
        val = list2val (ilist);
        switch (getSize (type)) {
        case 1:
@@ -629,9 +633,12 @@ printIvalStruct (symbol * sym, sym_link * type,
                if (IS_BITFIELD(sflds->type)) {
                        printIvalBitFields(&sflds,&iloop,oFile);
                } else {
-                       printIval (sflds, sflds->type, iloop, oFile);
+                       printIval (NULL, sflds->type, iloop, oFile);
                }
        }
+       if (iloop) {
+         werror (W_EXCESS_INITIALIZERS, "struct", sym->name, sym->lineDef);
+       }
        return;
 }
 
@@ -702,7 +709,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
   for (;;)
     {
       size++;
-      printIval (sym, type->next, iloop, oFile);
+      printIval (NULL, type->next, iloop, oFile);
       iloop = (iloop ? iloop->next : NULL);
 
 
@@ -716,7 +723,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
       if (!--lcnt) {
        /* if initializers left */
        if (iloop) {
-         werror (W_EXESS_ARRAY_INITIALIZERS, sym->name, sym->lineDef);
+         werror (W_EXCESS_INITIALIZERS, "array", sym->name, sym->lineDef);
        }
        break;
       }
@@ -964,7 +971,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
   /* if type is SPECIFIER */
   if (IS_SPEC (type))
     {
-      printIvalType (type, ilist, oFile);
+      printIvalType (sym, type, ilist, oFile);
       return;
     }
 }