Commit 138c94ea by Richard Kenner

(left_shift): Ignore integer overflow.

From-SVN: r9915
parent 245391da
...@@ -898,21 +898,15 @@ left_shift (a, b) ...@@ -898,21 +898,15 @@ left_shift (a, b)
struct constant *a; struct constant *a;
unsigned long b; unsigned long b;
{ {
/* It's unclear from the C standard whether shifts can overflow.
The following code ignores overflow; perhaps a C standard
interpretation ruling is needed. */
if (b >= HOST_BITS_PER_LONG) if (b >= HOST_BITS_PER_LONG)
{ return 0;
if (! a->unsignedp && a->value != 0)
integer_overflow ();
return 0;
}
else if (a->unsignedp) else if (a->unsignedp)
return (unsigned long) a->value << b; return (unsigned long) a->value << b;
else else
{ return a->value << b;
long l = a->value << b;
if (l >> b != a->value)
integer_overflow ();
return l;
}
} }
static long static long
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment