improved the generation of floating-point messages
This commit is contained in:
parent
63e64680bd
commit
44d9a8b42d
2 changed files with 19 additions and 7 deletions
|
@ -326,6 +326,9 @@ int2int(expp, tp)
|
||||||
return exp->ex_type->tp_fund;
|
return exp->ex_type->tp_fund;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* With compile-time constants, we don't set fp_used, since this is done
|
||||||
|
* only when necessary in eval.c.
|
||||||
|
*/
|
||||||
int2float(expp, tp)
|
int2float(expp, tp)
|
||||||
register struct expr **expp;
|
register struct expr **expp;
|
||||||
struct type *tp;
|
struct type *tp;
|
||||||
|
@ -336,7 +339,6 @@ int2float(expp, tp)
|
||||||
register struct expr *exp = *expp;
|
register struct expr *exp = *expp;
|
||||||
int uns = (*expp)->ex_type->tp_unsigned;
|
int uns = (*expp)->ex_type->tp_unsigned;
|
||||||
|
|
||||||
fp_used = 1;
|
|
||||||
if (is_cp_cst(exp)) {
|
if (is_cp_cst(exp)) {
|
||||||
*expp = new_expr();
|
*expp = new_expr();
|
||||||
**expp = *exp;
|
**expp = *exp;
|
||||||
|
@ -351,7 +353,10 @@ int2float(expp, tp)
|
||||||
flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns);
|
flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns);
|
||||||
exp->FL_DATLAB = 0;
|
exp->FL_DATLAB = 0;
|
||||||
}
|
}
|
||||||
else *expp = arith2arith(tp, INT2FLOAT, *expp);
|
else {
|
||||||
|
fp_used = 1;
|
||||||
|
*expp = arith2arith(tp, INT2FLOAT, *expp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float2int(expp, tp)
|
float2int(expp, tp)
|
||||||
|
@ -363,7 +368,6 @@ float2int(expp, tp)
|
||||||
*/
|
*/
|
||||||
register struct expr *ex = *expp;
|
register struct expr *ex = *expp;
|
||||||
|
|
||||||
fp_used = 1;
|
|
||||||
if (is_fp_cst(ex)) {
|
if (is_fp_cst(ex)) {
|
||||||
arith ar = flt_flt2arith(&ex->FL_ARITH, tp->tp_unsigned);
|
arith ar = flt_flt2arith(&ex->FL_ARITH, tp->tp_unsigned);
|
||||||
|
|
||||||
|
@ -377,7 +381,10 @@ float2int(expp, tp)
|
||||||
ex->VL_CLASS = Const;
|
ex->VL_CLASS = Const;
|
||||||
ex->VL_VALUE = ar;
|
ex->VL_VALUE = ar;
|
||||||
cut_size(ex);
|
cut_size(ex);
|
||||||
} else *expp = arith2arith(tp, FLOAT2INT, ex);
|
} else {
|
||||||
|
fp_used = 1;
|
||||||
|
*expp = arith2arith(tp, FLOAT2INT, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float2float(expp, tp)
|
float2float(expp, tp)
|
||||||
|
@ -390,11 +397,12 @@ float2float(expp, tp)
|
||||||
if the expression is a constant.
|
if the expression is a constant.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fp_used = 1;
|
|
||||||
if (is_fp_cst(*expp))
|
if (is_fp_cst(*expp))
|
||||||
(*expp)->ex_type = tp;
|
(*expp)->ex_type = tp;
|
||||||
else
|
else {
|
||||||
|
fp_used = 1;
|
||||||
*expp = arith2arith(tp, FLOAT2FLOAT, *expp);
|
*expp = arith2arith(tp, FLOAT2FLOAT, *expp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
array2pointer(exp)
|
array2pointer(exp)
|
||||||
|
|
|
@ -89,6 +89,7 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
if (gencode) {
|
if (gencode) {
|
||||||
label datlab = data_label();
|
label datlab = data_label();
|
||||||
|
|
||||||
|
fp_used = 1;
|
||||||
if (!expr->FL_VALUE) {
|
if (!expr->FL_VALUE) {
|
||||||
expr->FL_VALUE = Malloc(FLT_STRLEN);
|
expr->FL_VALUE = Malloc(FLT_STRLEN);
|
||||||
flt_flt2str(&(expr->FL_ARITH), expr->FL_VALUE, FLT_STRLEN);
|
flt_flt2str(&(expr->FL_ARITH), expr->FL_VALUE, FLT_STRLEN);
|
||||||
|
@ -938,9 +939,12 @@ load_val(expr, rlval)
|
||||||
else {
|
else {
|
||||||
register struct idf *id = expr->VL_IDF;
|
register struct idf *id = expr->VL_IDF;
|
||||||
register struct def *df = id->id_def;
|
register struct def *df = id->id_def;
|
||||||
|
int fund = df->df_type->tp_fund;
|
||||||
|
|
||||||
ASSERT(ISNAME(expr));
|
ASSERT(ISNAME(expr));
|
||||||
if (df->df_type->tp_fund == FUNCTION) {
|
if (fund == FLOAT || fund == DOUBLE || fund == LNGDBL)
|
||||||
|
fp_used = 1;
|
||||||
|
if (fund == FUNCTION) {
|
||||||
/* the previous statement tried to catch a function
|
/* the previous statement tried to catch a function
|
||||||
identifier, which may be cast to a pointer to a
|
identifier, which may be cast to a pointer to a
|
||||||
function.
|
function.
|
||||||
|
|
Loading…
Add table
Reference in a new issue