etype = getSpec (type);
SPEC_SCLS (etype) = (SPEC_SCLS (petype) == S_REGISTER ?
SPEC_SCLS (etype) : SPEC_SCLS (petype));
+ SPEC_OCLS (etype) = (SPEC_SCLS (petype) == S_REGISTER ?
+ SPEC_OCLS (etype) : SPEC_OCLS (petype));
if (IS_SPEC (type))
SPEC_CONST (type) |= SPEC_CONST (stype);
else
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++;
return rType;
}
+int
+comparePtrType (sym_link * dest, sym_link * src, bool bMustCast)
+{
+ int res;
+
+ if (IS_VOID (src->next) && IS_VOID (dest->next))
+ return bMustCast ? -1 : 1;
+ if ((IS_VOID (src->next) && !IS_VOID (dest->next)) ||
+ (!IS_VOID (src->next) && IS_VOID (dest->next)) )
+ return -1;
+ res = compareType (dest->next, src->next);
+ if (res == 1)
+ return bMustCast ? -1 : 1;
+ else if (res == -2)
+ return -2;
+ else
+ return 0;
+}
+
/*--------------------------------------------------------------------*/
-/* compareType - will do type check return 1 if match, -1 if castable */
+/* compareType - will do type check return 1 if match, 0 if no match, */
+/* -1 if castable, -2 if only signedness differs */
/*--------------------------------------------------------------------*/
int
compareType (sym_link * dest, sym_link * src)
return -1;
if (IS_FUNC (dest->next) && IS_VOID(src->next))
return -1;
- return compareType (dest->next, src->next);
+ return comparePtrType(dest, src, FALSE);
}
if (DCL_TYPE (src) == DCL_TYPE (dest))
{
//checkFunction(src,dest);
}
- return compareType (dest->next, src->next);
+ return comparePtrType(dest, src, FALSE);
}
if (IS_PTR (dest) && IS_GENPTR (src) && IS_VOID(src->next))
{
((DCL_TYPE(src) == POINTER) && (DCL_TYPE(dest) == IPOINTER))
))
{
- if (compareType (dest->next, src->next))
- return -1;
- else
- return 0;
+ return comparePtrType(dest, src, TRUE);
}
if (IS_PTR (dest) && IS_ARRAY (src))
{
return -1;
if (SPEC_USIGN (dest) != SPEC_USIGN (src))
- return -1;
+ return -2;
return 1;
}
}
break;
case S_AUTO:
+ DCL_TYPE (val->type) = PTR_TYPE(SPEC_OCLS(val->etype));
+ break;
case S_DATA:
case S_REGISTER:
DCL_TYPE (val->type) = POINTER;