From 44d9a8b42d16ef2158c54d4d617377f45b949a0e Mon Sep 17 00:00:00 2001 From: eck Date: Wed, 28 Feb 1990 14:51:35 +0000 Subject: [PATCH] improved the generation of floating-point messages --- lang/cem/cemcom.ansi/arith.c | 20 ++++++++++++++------ lang/cem/cemcom.ansi/eval.c | 6 +++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 00fee355e..eacc7d9ea 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -326,6 +326,9 @@ int2int(expp, tp) 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) register struct expr **expp; struct type *tp; @@ -336,7 +339,6 @@ int2float(expp, tp) register struct expr *exp = *expp; int uns = (*expp)->ex_type->tp_unsigned; - fp_used = 1; if (is_cp_cst(exp)) { *expp = new_expr(); **expp = *exp; @@ -351,7 +353,10 @@ int2float(expp, tp) flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns); exp->FL_DATLAB = 0; } - else *expp = arith2arith(tp, INT2FLOAT, *expp); + else { + fp_used = 1; + *expp = arith2arith(tp, INT2FLOAT, *expp); + } } float2int(expp, tp) @@ -363,7 +368,6 @@ float2int(expp, tp) */ register struct expr *ex = *expp; - fp_used = 1; if (is_fp_cst(ex)) { arith ar = flt_flt2arith(&ex->FL_ARITH, tp->tp_unsigned); @@ -377,7 +381,10 @@ float2int(expp, tp) ex->VL_CLASS = Const; ex->VL_VALUE = ar; cut_size(ex); - } else *expp = arith2arith(tp, FLOAT2INT, ex); + } else { + fp_used = 1; + *expp = arith2arith(tp, FLOAT2INT, ex); + } } float2float(expp, tp) @@ -390,11 +397,12 @@ float2float(expp, tp) if the expression is a constant. */ - fp_used = 1; if (is_fp_cst(*expp)) (*expp)->ex_type = tp; - else + else { + fp_used = 1; *expp = arith2arith(tp, FLOAT2FLOAT, *expp); + } } array2pointer(exp) diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 1b8b3da40..8c0173c75 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -89,6 +89,7 @@ EVAL(expr, val, code, true_label, false_label) if (gencode) { label datlab = data_label(); + fp_used = 1; if (!expr->FL_VALUE) { expr->FL_VALUE = Malloc(FLT_STRLEN); flt_flt2str(&(expr->FL_ARITH), expr->FL_VALUE, FLT_STRLEN); @@ -938,9 +939,12 @@ load_val(expr, rlval) else { register struct idf *id = expr->VL_IDF; register struct def *df = id->id_def; + int fund = df->df_type->tp_fund; 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 identifier, which may be cast to a pointer to a function. -- 2.34.1