From 8d4ee14580ea23a6c1e5c2a975c49eec0fd3c206 Mon Sep 17 00:00:00 2001 From: johanknol Date: Mon, 12 Nov 2001 17:14:17 +0000 Subject: [PATCH] fixed bug #478037 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1576 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCast.c | 4 ++-- src/SDCCglue.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/SDCCast.c b/src/SDCCast.c index f04159bf..5d17fab5 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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; } diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 55487f37..4523afe0 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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; } } -- 2.47.2