I have discovered code generation problem on AMD64. The patch below
corrects code generation. It causes spurious warnings in some other
tests (fjf1014.pas, fjf1021h.pas, fjf1021i.pas, fjf768c.pas,
fjf768e.pas, fjf768f.pas) but those will require separate fix.
In principle other platforms may be affected -- in particular the
problem on Mac OSX looks related.
diff -u p.orig/expressions.c p/expressions.c
--- p.orig/expressions.c 2005-02-16 04:38:36.000000000 +0100
+++ p/expressions.c 2005-02-19 05:17:58.200156608 +0100
@@ -259,20 +259,23 @@
{
tree cond, t;
int side_effects = TREE_SIDE_EFFECTS (expr);
- expr = save_expr (expr);
- if (TREE_CODE (expr) == SAVE_EXPR)
- TREE_SIDE_EFFECTS (expr) = side_effects;
- cond = chklo ? build_implicit_pascal_binary_op (LT_EXPR, expr, min) : NULL_TREE;
+ tree tmpvar = make_new_variable("range_check", TREE_TYPE (expr));
+ tree tv;
+ cond = chklo ? build_implicit_pascal_binary_op (LT_EXPR, tmpvar, min) : NULL_TREE;
if (chkhi)
{
- tree cond2 = build_implicit_pascal_binary_op (GT_EXPR, expr, max);
+ tree cond2 = build_implicit_pascal_binary_op (GT_EXPR, tmpvar, max);
cond = cond ? build_pascal_binary_op (TRUTH_ORIF_EXPR, cond, cond2) : cond2;
}
- t = save_expr (build (COND_EXPR, TREE_TYPE (expr), cond, build (COMPOUND_EXPR,
- TREE_TYPE (expr), build_predef_call (co->range_checking > 1 ? p_IORangeCheckError : p_RangeCheckError,
- NULL_TREE), expr), expr));
- if (TREE_CODE (t) == SAVE_EXPR)
- TREE_SIDE_EFFECTS (t) = side_effects;
+ t = build (COMPOUND_EXPR, TREE_TYPE (expr),
+ build_predef_call (co->range_checking > 1 ? p_IORangeCheckError : p_RangeCheckError,
+ NULL_TREE), tmpvar);
+ t = build (COND_EXPR, TREE_TYPE (expr), cond, t, tmpvar);
+ tv = build (MODIFY_EXPR, TREE_TYPE (expr), tmpvar, expr);
+ PASCAL_VALUE_ASSIGNED (tmpvar) = 1;
+ TREE_SIDE_EFFECTS (tv) = 1;
+ t = build (COMPOUND_EXPR, TREE_TYPE (expr), tv, t);
+ TREE_SIDE_EFFECTS (t) = side_effects;
return t;
}
}
--
Waldek Hebisch
hebisch(a)math.uni.wroc.pl