ch7cast(expp, CAST, tp);
else {
if ((*expp)->ex_type != error_type)
- error("%s on %s and pointer",
+ expr_error(*expp, "%s on %s and pointer",
symbol2str(oper),
symbol2str((*expp)->ex_type->tp_fund)
);
)
{}
else
- warning("%s on enum", symbol2str(oper));
+ expr_warning(*expp, "%s on enum", symbol2str(oper));
int2int(expp, int_type);
break;
case FLOAT:
break;
#endif NOBITFIELD
default:
- error("operator %s on non-numerical operand (%s)",
+ expr_error(*expp, "operator %s on non-numerical operand (%s)",
symbol2str(oper), symbol2str(fund));
case ERRONEOUS:
erroneous2int(expp);
if (fund != INT && fund != LONG) {
if (fund != ERRONEOUS)
- error("%s operand to %s",
+ expr_error(*expp, "%s operand to %s",
symbol2str(fund), symbol2str(oper));
erroneous2int(expp);
/* fund = INT; */
case DOUBLE:
break;
default:
- error("%s operand to %s",
+ expr_error(*expp, "%s operand to %s",
symbol2str(fund), symbol2str(oper));
case ERRONEOUS:
erroneous2int(expp);
tp = sd->sd_stype;
break;
default:
- error("-> applied to %s",
+ expr_error(*expp, "-> applied to %s",
symbol2str(tp->tp_fund));
case ERRONEOUS:
(*expp)->ex_type = error_type;
else { /* oper == '.' */
/* filter out illegal expressions "non_lvalue.sel" */
if (!(*expp)->ex_lvalue) {
- error("dot requires lvalue");
+ expr_error(*expp, "dot requires lvalue");
(*expp)->ex_type = error_type;
return;
}
break;
default:
if (!is_anon_idf(idf))
- error("selector %s applied to %s",
+ expr_error(*expp, "selector %s applied to %s",
idf->id_text, symbol2str(tp->tp_fund));
case ERRONEOUS:
(*expp)->ex_type = error_type;
register int fund = (*expp)->ex_type->tp_fund;
if (!(*expp)->ex_lvalue) {
- error("no lvalue with %s", symbol2str(oper));
+ expr_error(*expp, "no lvalue with %s", symbol2str(oper));
return;
}
if (fund == ENUM) {
- warning("%s on enum", symbol2str(oper));
+ expr_warning(*expp, "%s on enum", symbol2str(oper));
addend = (arith)1;
}
else
#endif NOBITFIELD
else {
if ((*expp)->ex_type != error_type)
- error("%s on %s",
+ expr_error(*expp, "%s on %s",
symbol2str(oper),
symbol2str((*expp)->ex_type->tp_fund)
);
tp->tp_fund == ENUM &&
oper != CAST
)
- warning("%s on enums of different types",
- symbol2str(oper));
+ expr_warning(*expp,
+ "%s on enums of different types",
+ symbol2str(oper));
int2int(expp, tp);
}
else
if (oldi && !i) {
if (oldtp->tp_fund == ENUM && oper != CAST)
- warning("conversion of enum to %s\n",
- symbol2str(tp->tp_fund));
+ expr_warning(*expp,
+ "conversion of enum to %s\n",
+ symbol2str(tp->tp_fund));
int2float(expp, tp);
}
else
else
if (oldtp->tp_fund == POINTER && tp->tp_fund == POINTER) {
if (oper != CAST)
- warning("incompatible pointers in %s",
+ expr_warning(*expp, "incompatible pointers in %s",
symbol2str(oper));
(*expp)->ex_type = tp; /* free conversion */
}
if (oldtp->tp_fund == POINTER && is_integral_type(tp)) {
/* from pointer to integral */
if (oper != CAST)
- warning("illegal conversion of pointer to %s",
+ expr_warning(*expp,
+ "illegal conversion of pointer to %s",
symbol2str(tp->tp_fund));
if (oldtp->tp_size > tp->tp_size)
- warning("conversion of pointer to %s loses accuracy",
+ expr_warning(*expp,
+ "conversion of pointer to %s loses accuracy",
symbol2str(tp->tp_fund));
if (oldtp->tp_size != tp->tp_size)
int2int(expp, tp);
if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0)
break;
default:
- warning("illegal conversion of %s to pointer",
+ expr_warning(*expp,
+ "illegal conversion of %s to pointer",
symbol2str(oldtp->tp_fund));
break;
}
if (oldtp->tp_size > tp->tp_size)
- warning("conversion of %s to pointer loses accuracy",
+ expr_warning(*expp,
+ "conversion of %s to pointer loses accuracy",
symbol2str(oldtp->tp_fund));
if (oldtp->tp_size != tp->tp_size)
int2int(expp, tp);
}
else
if (oldtp->tp_size == tp->tp_size && oper == CAST) {
- warning("dubious conversion based on equal size");
+ expr_warning(*expp, "dubious conversion based on equal size");
(*expp)->ex_type = tp; /* brute force */
}
else
/* We expect an lvalue */
if (!(*expp)->ex_lvalue) {
- error("no lvalue in lhs of %s", symbol2str(oper));
+ expr_error(*expp, "no lvalue in lhs of %s", symbol2str(oper));
(*expp)->ex_depth = 99; /* no direct store/load at EVAL() */
/* what is 99 ??? DG */
}
case TIMESAB:
case DIVAB:
case MODAB:
- if (!is_arith_type((*expp)->ex_type))
- error("%s on %s", symbol2str(oper), symbol2str(fund));
+ check_arith_type(expp, oper);
any2arith(&expr, oper);
ch7cast(&expr, CAST, (*expp)->ex_type);
break;
case MINAB:
any2arith(&expr, oper);
if (fund == POINTER) {
- if (!is_integral_type(expr->ex_type))
- error("%s on non-integral type (%s)",
- symbol2str(oper), symbol2str(fund));
+ check_integral_type(&expr, oper);
ch7bin(&expr, '*',
intexpr(
size_of_type(
)
);
}
- else
- if (!is_arith_type((*expp)->ex_type))
- error("%s on %s", symbol2str(oper), symbol2str(fund));
- else
+ else {
+ check_arith_type(expp, oper);
ch7cast(&expr, CAST, (*expp)->ex_type);
+ }
break;
case LEFTAB:
case RIGHTAB:
+ check_integral_type(expp, oper);
ch7cast(&expr, oper, int_type);
- if (!is_integral_type((*expp)->ex_type))
- error("%s on %s", symbol2str(oper), symbol2str(fund));
break;
case ANDAB:
case XORAB:
case ORAB:
- if (!is_integral_type((*expp)->ex_type))
- error("%s on %s", symbol2str(oper), symbol2str(fund));
+ check_integral_type(expp, oper);
ch7cast(&expr, oper, (*expp)->ex_type);
break;
}
}
}
+check_integral_type(expp, oper)
+ struct expr **expp;
+{
+ register struct expr *expr = *expp;
+
+ if (!is_integral_type(expr->ex_type)) {
+ expr_error(expr, "%s on non-integral type (%s)",
+ symbol2str(oper), symbol2str(expr->ex_type->tp_fund));
+ }
+ erroneous2int(expp);
+}
+
int
is_arith_type(tp)
struct type *tp;
return 0;
}
}
+
+check_arith_type(expp, oper)
+ struct expr **expp;
+{
+ register struct expr *expr = *expp;
+
+ if (!is_arith_type(expr->ex_type)) {
+ expr_error(expr, "%s on non-arithmetical type (%s)",
+ symbol2str(oper), symbol2str(expr->ex_type->tp_fund));
+ }
+ erroneous2int(expp);
+}
case ERRONEOUS:
return;
default:
- error("indexing an object of type %s",
+ expr_error(*expp,
+ "indexing an object of type %s",
symbol2str((*expp)->ex_type->tp_fund));
return;
}
}
if ((*expp)->ex_type->tp_fund != FUNCTION) {
if ((*expp)->ex_type != error_type)
- error("call of non-function (%s)",
+ expr_error(*expp, "call of non-function (%s)",
symbol2str((*expp)->ex_type->tp_fund));
/* leave the expression; it may still serve */
free_expression(expr); /* there go the parameters */
case '%':
fund = arithbalance(expp, oper, &expr);
if (fund == DOUBLE) {
- error("floating operand to %%");
+ expr_error(*expp, "floating operand to %%");
erroneous2int(expp);
}
else
|| is_struct_or_union(expr->ex_type->tp_fund)
) {
if ((*expp)->ex_type != expr->ex_type) {
- error("illegal balance");
+ expr_error(*expp, "illegal balance");
(*expp)->ex_type = error_type;
}
}
struct type *up_type = (*expp)->ex_type->tp_up;
if (up_type != expr->ex_type->tp_up) {
- error("subtracting incompatible pointers");
+ expr_error(*expp, "subtracting incompatible pointers");
free_expression(expr);
erroneous2int(expp);
return;
array2pointer(expp);
if ((*expp)->ex_type->tp_fund != POINTER) {
if ((*expp)->ex_type != error_type)
- error("* applied to non-pointer (%s)",
+ expr_error(*expp,
+ "* applied to non-pointer (%s)",
symbol2str((*expp)->ex_type->tp_fund));
(*expp)->ex_type = error_type;
}
else
#ifndef NOBITFIELD
if ((*expp)->ex_type->tp_fund == FIELD) {
- error("& applied to field variable");
+ expr_error(*expp, "& applied to field variable");
(*expp)->ex_type = error_type;
}
else
#endif NOBITFIELD
if (!(*expp)->ex_lvalue) {
- error("& applied to non-lvalue");
+ expr_error(*expp, "& applied to non-lvalue");
(*expp)->ex_type = error_type;
}
else {
be used as register anymore
*/
if (def->df_sc == REGISTER) {
- error("& on register variable not allowed");
+ expr_error(*expp,
+ "& on register variable not allowed");
(*expp)->ex_type = error_type;
break; /* break case '&' */
}
int fund = (*expp)->ex_type->tp_fund;
if (fund == FLOAT || fund == DOUBLE) {
- error("~ not allowed on %s operands",
+ expr_error(*expp, "~ not allowed on %s operands",
symbol2str(fund));
erroneous2int(expp);
break;