X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCglue.c;h=4194fa1c79c0d41bb16ea086b9226961ff44bfdf;hb=122a98623b6e7e3811469a36163421079652966a;hp=fed61f89773ab1a04a98cb739c954fc1bd125920;hpb=13b845db7aab0716af2fa014cbfcaa56dc4b0a73;p=fw%2Fsdcc diff --git a/src/SDCCglue.c b/src/SDCCglue.c index fed61f89..4194fa1c 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -703,48 +703,60 @@ void printIvalBitFields(symbol **sym, initList **ilist, struct dbuf_s * oBuf) symbol *lsym = *sym; initList *lilist = *ilist ; unsigned long ival = 0; - int size =0; - - do { - unsigned long i; - val = list2val(lilist); - if (size) { - if (SPEC_BLEN(lsym->etype) > 8) { - size += ((SPEC_BLEN (lsym->etype) / 8) + - (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0)); - } - } else { - size = ((SPEC_BLEN (lsym->etype) / 8) + - (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0)); - } + int size = 0; + + do + { + unsigned long i; + val = list2val (lilist); + if (size) + { + if (SPEC_BLEN (lsym->etype) > 8) + { + size += ((SPEC_BLEN (lsym->etype) / 8) + + (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0)); + } + } + else + { + size = ((SPEC_BLEN (lsym->etype) / 8) + + (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0)); + } - /* check if the literal value is within bounds */ - if (checkConstantRange (lsym->etype, val->etype, '=', FALSE) == CCR_OVL && + /* check if the literal value is within bounds */ + if (val && + checkConstantRange (lsym->etype, val->etype, '=', FALSE) == CCR_OVL && !options.lessPedantic) - { - werror (W_LIT_OVERFLOW); - } - i = ulFromVal(val); - i &= (1 << SPEC_BLEN (lsym->etype)) - 1; - i <<= SPEC_BSTR (lsym->etype); - ival |= i; - if (! ( lsym->next && - (IS_BITFIELD(lsym->next->type)) && - (SPEC_BSTR(lsym->next->etype)))) break; - lsym = lsym->next; - lilist = lilist ? lilist->next : NULL; - } while (1); - switch (size) { + { + werror (W_LIT_OVERFLOW); + } + + i = ulFromVal (val); + i &= (1 << SPEC_BLEN (lsym->etype)) - 1; + i <<= SPEC_BSTR (lsym->etype); + ival |= i; + if (!(lsym->next && + (IS_BITFIELD (lsym->next->type)) && + (SPEC_BSTR (lsym->next->etype)))) + break; + lsym = lsym->next; + lilist = lilist ? lilist->next : NULL; + } + while (1); + + switch (size) + { case 1: - dbuf_tprintf (oBuf, "\t!db !constbyte\n",ival); + dbuf_tprintf (oBuf, "\t!db !constbyte\n", ival); break; case 2: - dbuf_tprintf (oBuf, "\t!dw !constword\n",ival); + dbuf_tprintf (oBuf, "\t!dw !constword\n", ival); break; + case 4: dbuf_tprintf (oBuf, "\t!dw !constword,!constword\n", - (ival >> 16) & 0xffff, (ival & 0xffff)); + (ival >> 16) & 0xffff, (ival & 0xffff)); break; } *sym = lsym;