GENOPTIONS = -v
# Special #defines during compilation
+PROF = #-pg
CDEFS = $(EM_INCLUDES) $(LIB_INCLUDES)
-CFLAGS = $(CDEFS) $(COPTIONS) -O
-LDFLAGS = -i
+CFLAGS = $(CDEFS) $(COPTIONS) -O $(PROF)
+LDFLAGS = -i $(PROF)
# Grammar files and their objects
LSRC = tokenfile.g declar.g statement.g expression.g program.g ival.g
/* The expression *expp, which is of some integral type, is
converted to the floating type tp.
*/
+ register struct expr *exp = *expp;
+ char buf[32];
fp_used = 1;
- *expp = arith2arith(tp, INT2FLOAT, *expp);
+ if (is_cp_cst(exp)) {
+ *expp = new_expr();
+ **expp = *exp;
+ sprint(buf+1, "%ld", (long)(exp->VL_VALUE));
+ buf[0] = '-';
+ exp = *expp;
+ exp->ex_type = tp;
+ exp->ex_class = Float;
+ exp->FL_VALUE = Salloc(buf, (unsigned)strlen(buf)+1) + 1;
+ exp->FL_DATLAB = 0;
+ }
+ else *expp = arith2arith(tp, INT2FLOAT, *expp);
}
float2int(expp, tp)
#endif DEBUG
if (expr->ex_class == Float)
C_con_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
+#ifdef NOTDEF
+
+Coercion from int to float is now always done compile time.
+This, to accept declarations like
+double x = -(double)1;
+and also to prevent runtime coercions for compile-time constants.
+
else
if (expr->ex_class == Oper && expr->OP_OPER == INT2FLOAT) {
/* float f = 1; */
else
illegal_init_cst(expr);
}
+#endif NOTDEF
else
illegal_init_cst(expr);
break;