fprintf (stderr, "checkSClass: %s \n", sym->name);
}
- /* type is literal can happen for enums change
- to auto */
+ /* type is literal can happen for enums change to auto */
if (SPEC_SCLS (sym->etype) == S_LITERAL && !SPEC_ENUM (sym->etype))
SPEC_SCLS (sym->etype) = S_AUTO;
&& ( (SPEC_USIGN (etype1)
/* if this operand is promoted to a larger type,
then it will be promoted to a signed type */
- && !(getSize (etype1) < getSize (reType))
+ && !(bitsForType (etype1) < bitsForType (reType))
/* char require special handling */
&& !IS_CHAR (etype1))
|| /* same for 2nd operand */
(SPEC_USIGN (etype2)
- && !(getSize (etype2) < getSize (reType))
+ && !(bitsForType (etype2) < bitsForType (reType))
&& !IS_CHAR (etype2))
|| /* if both are 'unsigned char' and not promoted
let the result be unsigned too */
/* powof2 - returns power of two for the number if number is pow 2 */
/*-----------------------------------------------------------------*/
int
-powof2 (TYPE_UDWORD num)
+powof2 (TYPE_TARGET_ULONG num)
{
int nshifts = 0;
int n1s = 0;
{
for (muldivmod = 1; muldivmod < 3; muldivmod++)
{
- /* div and mod */
- SNPRINTF (buffer, sizeof(buffer),
- "_%s%s%s",
- smuldivmod[muldivmod],
- ssu[su],
- sbwd[bwd]);
- __muldiv[muldivmod][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
- FUNC_NONBANKED (__muldiv[muldivmod][bwd][su]->type) = 1;
+ /* div and mod : s8_t x s8_t -> s8_t should be s8_t x s8_t -> s16_t, see below */
+ if (!TARGET_IS_PIC16 || muldivmod != 1 || bwd != 0 || su != 0)
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "_%s%s%s",
+ smuldivmod[muldivmod],
+ ssu[su],
+ sbwd[bwd]);
+ __muldiv[muldivmod][bwd][su] = funcOfType (
+ _mangleFunctionName(buffer),
+ __multypes[bwd][su],
+ __multypes[bwd][su],
+ 2,
+ options.intlong_rent);
+ FUNC_NONBANKED (__muldiv[muldivmod][bwd][su]->type) = 1;
+ }
}
}
}
+
+ if (TARGET_IS_PIC16)
+ {
+ /* PIC16 port wants __divschar/__modschar to return an int, so that both
+ * 100 / -4 = -25 and -128 / -1 = 128 can be handled correctly
+ * (first one would have to be sign extended, second one must not be).
+ * Similarly, modschar should be handled, but the iCode introduces cast
+ * here and forces '% : s8 x s8 -> s8' ... */
+ su = 0; bwd = 0;
+ for (muldivmod = 1; muldivmod < 2; muldivmod++) {
+ SNPRINTF (buffer, sizeof(buffer),
+ "_%s%s%s",
+ smuldivmod[muldivmod],
+ ssu[su],
+ sbwd[bwd]);
+ __muldiv[muldivmod][bwd][su] = funcOfType (
+ _mangleFunctionName(buffer),
+ __multypes[1][su],
+ __multypes[bwd][su],
+ 2,
+ options.intlong_rent);
+ FUNC_NONBANKED (__muldiv[muldivmod][bwd][su]->type) = 1;
+ }
+ }
+
/* mul only */
muldivmod = 0;
/* byte */
" expected %s, got %s\n",
macro, args, file, line,
DECLSPEC2TXT(select), l ? DECLSPEC2TXT(l->class) : "null-link");
- exit(-1);
+ exit(EXIT_FAILURE);
return l; // never reached, makes compiler happy.
}