1444425: onebyte.c regression tes fails on pic16
are fiexed, probably by fixing
2048464: PIC16: fix genUminus - addresses not.c regression test
+ * src/SDCCsymt.c, src/SDCCglue.c,
+ support/regression/tests/bug-1981238.c:
+ applied patch 2076664: fix #1981238 + SIGSEGV in SDCCGlue.c
+ thanks to RvS
2008-08-30 Borut Razem <borut.razem AT siol.net>
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;
if (!loop->etype->select.s.b_signed)
SPEC_USIGN(loop->etype) = 1;
- SPEC_BLEN (loop->etype) = loop->bitVar;
-
if (loop->bitVar == BITVAR_PAD) {
/* A zero length bitfield forces padding */
- SPEC_BSTR (loop->etype) = bitOffset;
SPEC_BLEN (loop->etype) = 0;
- bitOffset = 8;
+ SPEC_BSTR (loop->etype) = bitOffset;
+ if (bitOffset > 0)
+ bitOffset = 8; /* padding is not needed when at bit 0 */
loop->offset = sum;
}
else {
+ SPEC_BLEN (loop->etype) = loop->bitVar;
+
if (bitOffset == 8) {
bitOffset = 0;
sum++;
--- /dev/null
+/*
+ bug1981238.c
+*/
+#include <testfwk.h>
+
+code struct {
+ char x:1;
+ char :0;
+ char d:2;
+ char b:6;
+} pad ={1, 2, 1};
+
+code struct {
+ int p:1;
+ int q:7;
+ int :0;
+ int s:1;
+ int t:7;
+} noPad ={1, 120, 1, 1, 127};
+
+code struct {
+ char :0;
+ char b;
+} initialNoPad[] ={{1, 2}, {3,4}};
+
+void testBitfield (void)
+{
+ ASSERT (sizeof (pad) == 2);
+ ASSERT (sizeof (noPad) == 2);
+ ASSERT (sizeof (initialNoPad[0]) == 1);
+}