{
/* The expressions *e1p and *e2p are balanced to be operands
of the arithmetic operator oper.
+ We check here if the EX_PTRDIFF flag should be retained.
+ They are set to zero in because one of the opreands might
+ have a floating type, in which case the flags shouldn't
+ travel upward in the expression tree.
*/
register int t1, t2, u1, u2;
int shifting = (oper == LEFT || oper == RIGHT
|| oper == LEFTAB || oper == RIGHTAB);
+ int ptrdiff = 0;
t1 = any2arith(e1p, oper);
t2 = any2arith(e2p, oper);
+
+ if (int_size != pointer_size) {
+ if (ptrdiff = ((*e1p)->ex_flags & EX_PTRDIFF)
+ || ((*e2p)->ex_flags & EX_PTRDIFF)) {
+ if (!((*e1p)->ex_flags & EX_PTRDIFF) && t1 == LONG)
+ ptrdiff = 0;
+ if (!((*e2p)->ex_flags & EX_PTRDIFF) && t2 == LONG
+ && !shifting)
+ ptrdiff = 0;
+ }
+ /* Now turn off ptrdiff flags */
+ (*e1p)->ex_flags &= ~EX_PTRDIFF;
+ (*e2p)->ex_flags &= ~EX_PTRDIFF;
+ }
+
/* Now t1 and t2 are either INT, LONG, FLOAT, DOUBLE, or LNGDBL */
/* If any operand has the type long double, the other operand
else
if (!u1 && u2 && !shifting)
t1 = int2int(e1p, (t2 == LONG) ? ulong_type : uint_type);
+
+ if (int_size != pointer_size) {
+ if (ptrdiff) {
+ (*e1p)->ex_flags |= EX_PTRDIFF;
+ (*e2p)->ex_flags |= EX_PTRDIFF;
+ }
+ }
}
relbalance(e1p, oper, e2p)
/* To handle default argument promotions
*/
any2opnd(expp, '(');
+ if (int_size != pointer_size)
+ if ((*expp)->ex_flags & EX_PTRDIFF)
+ expr_warning(*expp, "pointer difference caused long expression");
if ((*expp)->ex_type->tp_fund == FLOAT)
float2float(expp, double_type);
}
if (!expand_macro(repl, idf))
return 0;
InputLevel++;
- InsertText(repl->r_text, repl->r_ptr - repl->r_text);
+ InsertText(repl->r_text, (int)(repl->r_ptr - repl->r_text));
idf->id_macro->mc_flag |= NOREPLACE;
repl->r_level = InputLevel;
repl->next = ReplaceList;
/* When the identifier has an associated macro
replacement list, it's expanded.
*/
- idef = idf_hashed(buf, p - buf, hash);
+ idef = idf_hashed(buf, (int) (p - buf), hash);
if (NoExpandMacro || !replace(idef)) {
if ((idef->id_macro
&& (idef->id_macro->mc_flag & NOREPLACE))