gcj/83: Failure to compile try/finally?
Alexandre Petit-Bianco
apbianco@cygnus.com
Fri Feb 18 16:30:00 GMT 2000
The following reply was made to PR gcj/83; it has been noted by GNATS.
From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: gback@cs.utah.edu
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/83: Failure to compile try/finally?
Date: Fri, 18 Feb 2000 16:23:37 -0800 (PST)
gback@cs.utah.edu writes:
> The following program produces incorrect results when
> compiled from the java source.
> ...
> gcj cannot compile the .class file it generates with -C.
This PR actually exposes two problems. The first one has to do with
gcj not enforcing a correct order of evaluation for something like:
foo (a+b);
With `a' and `b' being of type String or returning something of type
String.
`b' is currently evaluated before `a', if `a' modifies `b', its new
value won't be used to construct the string. I believe this is fixed
with the patch below.
The second problem is a gcj verifier problem. I think we should file a
second PR with it.
On thing. I tried to rebuild libgcj with the patch, and I think it
exposes an other problem in check_init (I might have a patch for
that.) So, before I get a definite answer, I'm not checking anything
in.
Here's the patch to fix the order of evaluation problem. I'm filing an
other PR for the gcj's generated class to native.
./A
Fri Feb 18 16:18:04 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (patch_string): Call force_evaluation_order on the
completed string concatenation tree.
* expr.c (force_evaluation_order): Call force_evaluation_order on
function's arguments too.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.135
diff -u -p -r1.135 parse.y
--- parse.y 2000/02/15 22:54:21 1.135
+++ parse.y 2000/02/19 00:19:06
@@ -10272,6 +10272,8 @@ patch_string (node)
/* Temporary disable forbid the use of `this'. */
ctxp->explicit_constructor_p = 0;
ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
+ /* String concatenation arguments must be evaluated in order too. */
+ ret = force_evaluation_order (ret);
/* Restore it at its previous value */
ctxp->explicit_constructor_p = saved;
return ret;
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/expr.c,v
retrieving revision 1.59
diff -u -p -r1.59 expr.c
--- expr.c 2000/02/18 18:17:37 1.59
+++ expr.c 2000/02/19 00:19:06
@@ -2694,7 +2694,7 @@ force_evaluation_order (node)
for (cmp = NULL_TREE, arg = TREE_OPERAND (node, 1);
arg; arg = TREE_CHAIN (arg))
{
- tree saved = save_expr (TREE_VALUE (arg));
+ tree saved = save_expr (force_evaluation_order (TREE_VALUE (arg)));
cmp = (cmp == NULL_TREE ? saved :
build (COMPOUND_EXPR, void_type_node, cmp, saved));
TREE_VALUE (arg) = saved;
More information about the Java-prs
mailing list