Commit ca261cb4 by Kaveh R. Ghazi Committed by Kaveh Ghazi

cppexp.c (left_shift, [...]): Replace uses of long/HOST_BITS_PER_LONG with...

        * cppexp.c (left_shift, right_shift, parse_charconst, COMPARE,
        cpp_parse_expr): Replace uses of long/HOST_BITS_PER_LONG with
        HOST_WIDEST_INT/HOST_BITS_PER_WIDEST_INT.

From-SVN: r25447
parent e915b770
Thu Feb 25 23:33:06 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Thu Feb 25 23:33:06 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cppexp.c (left_shift, right_shift, parse_charconst, COMPARE,
cpp_parse_expr): Replace uses of long/HOST_BITS_PER_LONG with
HOST_WIDEST_INT/HOST_BITS_PER_WIDEST_INT.
* Makefile.in (cppmain.o, cpplib.o, cpphash.o, cppalloc.o, * Makefile.in (cppmain.o, cpplib.o, cpphash.o, cppalloc.o,
cpperror.o, cppexp.o, cppfiles.o, cppinit.o, fix-header.o, cpperror.o, cppexp.o, cppfiles.o, cppinit.o, fix-header.o,
scan-decls.o): Don't depend on machmode.h. scan-decls.o): Don't depend on machmode.h.
......
...@@ -77,8 +77,8 @@ Written by Per Bothner 1994. */ ...@@ -77,8 +77,8 @@ Written by Per Bothner 1994. */
#define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0) #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
static void integer_overflow PARAMS ((cpp_reader *)); static void integer_overflow PARAMS ((cpp_reader *));
static long left_shift PARAMS ((cpp_reader *, long, int, unsigned long)); static HOST_WIDEST_INT left_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, int, unsigned HOST_WIDEST_INT));
static long right_shift PARAMS ((cpp_reader *, long, int, unsigned long)); static HOST_WIDEST_INT right_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, int, unsigned HOST_WIDEST_INT));
#define ERROR 299 #define ERROR 299
#define OROR 300 #define OROR 300
...@@ -330,11 +330,11 @@ parse_charconst (pfile, start, end) ...@@ -330,11 +330,11 @@ parse_charconst (pfile, start, end)
if (cpp_lookup (pfile, (U_CHAR *)"__CHAR_UNSIGNED__", if (cpp_lookup (pfile, (U_CHAR *)"__CHAR_UNSIGNED__",
sizeof ("__CHAR_UNSIGNED__")-1, -1) sizeof ("__CHAR_UNSIGNED__")-1, -1)
|| ((result >> (num_bits - 1)) & 1) == 0) || ((result >> (num_bits - 1)) & 1) == 0)
op.value = result & ((unsigned long) ~0 op.value = result & ((unsigned HOST_WIDEST_INT) ~0
>> (HOST_BITS_PER_LONG - num_bits)); >> (HOST_BITS_PER_WIDEST_INT - num_bits));
else else
op.value = result | ~((unsigned long) ~0 op.value = result | ~((unsigned HOST_WIDEST_INT) ~0
>> (HOST_BITS_PER_LONG - num_bits)); >> (HOST_BITS_PER_WIDEST_INT - num_bits));
/* This is always a signed type. */ /* This is always a signed type. */
op.unsignedp = 0; op.unsignedp = 0;
...@@ -620,41 +620,41 @@ integer_overflow (pfile) ...@@ -620,41 +620,41 @@ integer_overflow (pfile)
cpp_pedwarn (pfile, "integer overflow in preprocessor expression"); cpp_pedwarn (pfile, "integer overflow in preprocessor expression");
} }
static long static HOST_WIDEST_INT
left_shift (pfile, a, unsignedp, b) left_shift (pfile, a, unsignedp, b)
cpp_reader *pfile; cpp_reader *pfile;
long a; HOST_WIDEST_INT a;
int unsignedp; int unsignedp;
unsigned long b; unsigned HOST_WIDEST_INT b;
{ {
if (b >= HOST_BITS_PER_LONG) if (b >= HOST_BITS_PER_WIDEST_INT)
{ {
if (! unsignedp && a != 0) if (! unsignedp && a != 0)
integer_overflow (pfile); integer_overflow (pfile);
return 0; return 0;
} }
else if (unsignedp) else if (unsignedp)
return (unsigned long) a << b; return (unsigned HOST_WIDEST_INT) a << b;
else else
{ {
long l = a << b; HOST_WIDEST_INT l = a << b;
if (l >> b != a) if (l >> b != a)
integer_overflow (pfile); integer_overflow (pfile);
return l; return l;
} }
} }
static long static HOST_WIDEST_INT
right_shift (pfile, a, unsignedp, b) right_shift (pfile, a, unsignedp, b)
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_reader *pfile ATTRIBUTE_UNUSED;
long a; HOST_WIDEST_INT a;
int unsignedp; int unsignedp;
unsigned long b; unsigned HOST_WIDEST_INT b;
{ {
if (b >= HOST_BITS_PER_LONG) if (b >= HOST_BITS_PER_WIDEST_INT)
return unsignedp ? 0 : a >> (HOST_BITS_PER_LONG - 1); return unsignedp ? 0 : a >> (HOST_BITS_PER_WIDEST_INT - 1);
else if (unsignedp) else if (unsignedp)
return (unsigned long) a >> b; return (unsigned HOST_WIDEST_INT) a >> b;
else else
return a >> b; return a >> b;
} }
...@@ -679,7 +679,7 @@ right_shift (pfile, a, unsignedp, b) ...@@ -679,7 +679,7 @@ right_shift (pfile, a, unsignedp, b)
#define COMPARE(OP) \ #define COMPARE(OP) \
top->unsignedp = 0;\ top->unsignedp = 0;\
top->value = (unsigned1 || unsigned2) \ top->value = (unsigned1 || unsigned2) \
? (unsigned long) v1 OP (unsigned long) v2 : (v1 OP v2) ? (unsigned HOST_WIDEST_INT) v1 OP (unsigned HOST_WIDEST_INT) v2 : (v1 OP v2)
/* Parse and evaluate a C expression, reading from PFILE. /* Parse and evaluate a C expression, reading from PFILE.
Returns the value of the expression. */ Returns the value of the expression. */
...@@ -789,7 +789,7 @@ cpp_parse_expr (pfile) ...@@ -789,7 +789,7 @@ cpp_parse_expr (pfile)
/* Push an operator, and check if we can reduce now. */ /* Push an operator, and check if we can reduce now. */
while (top->rprio > lprio) while (top->rprio > lprio)
{ {
long v1 = top[-1].value, v2 = top[0].value; HOST_WIDEST_INT v1 = top[-1].value, v2 = top[0].value;
int unsigned1 = top[-1].unsignedp, unsigned2 = top[0].unsignedp; int unsigned1 = top[-1].unsignedp, unsigned2 = top[0].unsignedp;
top--; top--;
if ((top[1].flags & LEFT_OPERAND_REQUIRED) if ((top[1].flags & LEFT_OPERAND_REQUIRED)
...@@ -844,7 +844,7 @@ cpp_parse_expr (pfile) ...@@ -844,7 +844,7 @@ cpp_parse_expr (pfile)
case '*': case '*':
top->unsignedp = unsigned1 || unsigned2; top->unsignedp = unsigned1 || unsigned2;
if (top->unsignedp) if (top->unsignedp)
top->value = (unsigned long) v1 * v2; top->value = (unsigned HOST_WIDEST_INT) v1 * v2;
else if (!skip_evaluation) else if (!skip_evaluation)
{ {
top->value = v1 * v2; top->value = v1 * v2;
...@@ -864,7 +864,7 @@ cpp_parse_expr (pfile) ...@@ -864,7 +864,7 @@ cpp_parse_expr (pfile)
} }
top->unsignedp = unsigned1 || unsigned2; top->unsignedp = unsigned1 || unsigned2;
if (top->unsignedp) if (top->unsignedp)
top->value = (unsigned long) v1 / v2; top->value = (unsigned HOST_WIDEST_INT) v1 / v2;
else else
{ {
top->value = v1 / v2; top->value = v1 / v2;
...@@ -882,7 +882,7 @@ cpp_parse_expr (pfile) ...@@ -882,7 +882,7 @@ cpp_parse_expr (pfile)
} }
top->unsignedp = unsigned1 || unsigned2; top->unsignedp = unsigned1 || unsigned2;
if (top->unsignedp) if (top->unsignedp)
top->value = (unsigned long) v1 % v2; top->value = (unsigned HOST_WIDEST_INT) v1 % v2;
else else
top->value = v1 % v2; top->value = v1 % v2;
break; break;
......
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