Commit 75aef48a by Neil Booth Committed by Neil Booth

cppexp.c (ALWAYS_EVAL): Remove.

	* cppexp.c (ALWAYS_EVAL): Remove.
	(optab, reduce): Always evaluate.
	(num_unary_op, num_binary_op, num_div_op): Issue diagnostics
	only if not skipping evaluation.
testsuite:
	* gcc.dg/cpp/expr.c: New tests.

From-SVN: r55595
parent 72a5503d
2002-07-19 Neil Booth <neil@daikokuya.co.uk>
* cppexp.c (ALWAYS_EVAL): Remove.
(optab, reduce): Always evaluate.
(num_unary_op, num_binary_op, num_div_op): Issue diagnostics
only if not skipping evaluation.
2002-07-19 Marek Michalkiewicz <marekm@amelek.gda.pl>
* config/avr/avr.c (debug_hard_reg_set): Remove.
......
......@@ -630,12 +630,9 @@ The parser assumes all shifted operators require a left operand unless
the flag NO_L_OPERAND is set. These semantics are automatic; any
extra semantics need to be handled with operator-specific code. */
/* Flags. ALWAYS_EVAL is for operators that should be evaluated even
if skip_eval is true; perhaps they are invalid and require a
diagnostic, or they might modify skip_eval. */
/* Flags. */
#define NO_L_OPERAND (1 << 0)
#define LEFT_ASSOC (1 << 1)
#define ALWAYS_EVAL (1 << 2)
/* Operator to priority map. Must be in the same order as the first
N entries of enum cpp_ttype. */
......@@ -664,12 +661,12 @@ static const struct operator
/* MAX */ {10, LEFT_ASSOC},
/* COMPL */ {16, NO_L_OPERAND},
/* AND_AND */ {6, LEFT_ASSOC | ALWAYS_EVAL},
/* OR_OR */ {5, LEFT_ASSOC | ALWAYS_EVAL},
/* QUERY */ {3, ALWAYS_EVAL},
/* COLON */ {4, LEFT_ASSOC | ALWAYS_EVAL},
/* AND_AND */ {6, LEFT_ASSOC},
/* OR_OR */ {5, LEFT_ASSOC},
/* QUERY */ {3, 0},
/* COLON */ {4, LEFT_ASSOC},
/* COMMA */ {2, LEFT_ASSOC},
/* OPEN_PAREN */ {1, NO_L_OPERAND | ALWAYS_EVAL},
/* OPEN_PAREN */ {1, NO_L_OPERAND},
/* CLOSE_PAREN */ {0, 0},
/* EOF */ {0, 0},
/* EQ_EQ */ {11, LEFT_ASSOC},
......@@ -863,7 +860,6 @@ reduce (pfile, top, op)
prio = optab[op].prio - ((optab[op].flags & LEFT_ASSOC) != 0);
while (prio < optab[top->op].prio)
{
if (!pfile->state.skip_eval || optab[top->op].flags & ALWAYS_EVAL)
switch (top->op)
{
case CPP_UPLUS:
......@@ -1273,7 +1269,7 @@ num_unary_op (pfile, num, op)
switch (op)
{
case CPP_UPLUS:
if (CPP_WTRADITIONAL (pfile))
if (CPP_WTRADITIONAL (pfile) && !pfile->state.skip_eval)
cpp_error (pfile, DL_WARNING,
"traditional C rejects the unary plus operator");
num.overflow = false;
......@@ -1375,7 +1371,7 @@ num_binary_op (pfile, lhs, rhs, op)
/* Comma. */
default: /* case CPP_COMMA: */
if (CPP_PEDANTIC (pfile))
if (CPP_PEDANTIC (pfile) && !pfile->state.skip_eval)
cpp_error (pfile, DL_PEDWARN,
"comma operator in operand of #if");
lhs = rhs;
......@@ -1512,6 +1508,7 @@ num_div_op (pfile, lhs, rhs, op)
}
else
{
if (!pfile->state.skip_eval)
cpp_error (pfile, DL_ERROR, "division by zero in #if");
return lhs;
}
......
2002-07-19 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/cpp/expr.c: New tests.
2002 07-18 David Edelsohn <edelsohn@gnu.org>
* g++.dg/opt/pr6713.C: Add template instantiation.
......
/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* Test we get signedness of ?: operator correct. We would skip
evaluation of one argument, and might therefore not transfer its
unsignedness to the result. */
/* Neil Booth, 19 Jul 2002. */
#if (1 ? -2: 0 + 1U) < 0
#error /* { dg-bogus "error" } */
#endif
#if (0 ? 0 + 1U: -2) < 0
#error /* { dg-bogus "error" } */
#endif
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