X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCast.c;h=896a9f6bad54c41db310c4aaff5f08817846b2d9;hb=259fb25d65ee3cd76034fce37e3e8cbffb2aa566;hp=2e6d1f8e8cdda4e9a7f602fd2be6c76608d09b03;hpb=e2abd6205dc0c47c0e0e174ab3872246613b1e06;p=fw%2Fsdcc diff --git a/src/SDCCast.c b/src/SDCCast.c index 2e6d1f8e..896a9f6b 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -971,7 +971,7 @@ createIvalType (ast * sym, sym_link * type, initList * ilist) /* createIvalStruct - generates initial value for structures */ /*-----------------------------------------------------------------*/ static ast * -createIvalStruct (ast * sym, sym_link * type, initList * ilist, ast *rootValue) +createIvalStruct (ast *sym, sym_link *type, initList *ilist, ast *rootValue) { ast *rast = NULL; ast *lAst; @@ -979,7 +979,6 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist, ast *rootValue) initList *iloop; sym_link * etype = getSpec (type); - sflds = SPEC_STRUCT (type)->fields; if (ilist && ilist->type != INIT_DEEP) { werror (E_INIT_STRUCT, ""); @@ -988,20 +987,20 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist, ast *rootValue) iloop = ilist ? ilist->init.deep : NULL; - for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) + for (sflds = SPEC_STRUCT (type)->fields; sflds; sflds = sflds->next) { /* if we have come to end */ if (!iloop && (!AST_SYMBOL (rootValue)->islocal || SPEC_STAT (etype))) + break; + + if (!IS_BITFIELD (sflds->type) || !SPEC_BUNNAMED (sflds->etype)) { - break; + sflds->implicit = 1; + lAst = newNode (PTR_OP, newNode ('&', sym, NULL), newAst_VALUE (symbolVal (sflds))); + lAst = decorateType (resolveSymbols (lAst), RESULT_TYPE_NONE); + rast = decorateType (resolveSymbols (createIval (lAst, sflds->type, iloop, rast, rootValue)), RESULT_TYPE_NONE); + iloop = iloop ? iloop->next : NULL; } - - sflds->implicit = 1; - lAst = newNode (PTR_OP, newNode ('&', sym, NULL), newAst_VALUE (symbolVal (sflds))); - lAst = decorateType (resolveSymbols (lAst), RESULT_TYPE_NONE); - rast = decorateType (resolveSymbols (createIval (lAst, sflds->type, - iloop, rast, rootValue)), - RESULT_TYPE_NONE); } if (iloop) @@ -1012,7 +1011,7 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist, ast *rootValue) sym->opval.val->sym->name); else werrorfl (sym->filename, sym->lineno, E_INIT_COUNT); - } + } return rast; }