Freenet compilation errors.
Per Bothner
per@bothner.com
Sat Jan 6 23:49:00 GMT 2001
I've tracked down the cause of the "Missing return statement" bug.
The problem is these lines in patch_exit_expr in parse.y:
if (! integer_zerop (TREE_OPERAND (node, 0))
&& ctxp->current_loop != NULL_TREE
&& TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
Here the CAN_COMPLETE_NORMALLY flag is set on the loop,
but only if TREE_OPERAND (node, 0) is not a false constant.
Unfortunately, TREE_OPERAND (node, 0) *should* be false,
but it is not viewed as constant, and so CAN_COMPLETE_NORMALLY
is set to true.
So why is TREE_OPERAND (node, 0) not false? It is set in the
statement above:
TREE_OPERAND (node, 0) =
fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
This negates the "true", and then constant folds it. The result
*should* be false, but it is not a constant, because the true
constant was wrapped in an EXPR_WITH_FILE_LOCATION node.
One might "fix" by putting in a special case for EXPR_WITH_FILE_LOCATION
in patch_exit_expr, but I think that is wrong: Any constant expression
might be wrapped in a EXPR_WITH_FILE_LOCATION. Thus we need to strip
off EXPR_WITH_FILE_LOCATION before doing constant folding - but we
should do it *generally*, not a special case for patch_exit_expr.
I don't there is much point in having a EXPR_WITH_FILE_LOCATION
wrapped around a constant, since a constant is never executed anyway.
I suggest the following patch:
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.238
diff -u -p -r1.238 parse.y
--- parse.y 2000年12月18日 21:23:02 1.238
+++ parse.y 2001年01月07日 07:43:25
@@ -11475,9 +11475,9 @@ java_complete_lhs (node)
EXPR_WFL_NODE (node) = body;
TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
- if (body == empty_stmt_node)
+ if (body == empty_stmt_node || TREE_CONSTANT (body))
{
- /* Optimization; makes it easier to detect empty bodies. */
+ /* Makes it easier to constant fold, detect empty bodies. */
return body;
}
if (body == error_mark_node)
Index: lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lex.c,v
retrieving revision 1.55
diff -u -p -r1.55 lex.c
--- lex.c 2000年12月13日 22:47:13 1.55
+++ lex.c 2001年01月07日 07:43:26
@@ -1642,7 +1642,10 @@ static tree
build_wfl_node (node)
tree node;
{
- return build_expr_wfl (node, ctxp->filename, ctxp->elc.line, ctxp->elc.col);
+ node = build_expr_wfl (node, ctxp->filename, ctxp->elc.line, ctxp->elc.col);
+ /* Prevent java_complete_lhs from short-circuiting node (if constant). */
+ TREE_TYPE (node) = NULL_TREE;
+ return node;
}
#endif
Does this look reasonable? (I think this is the first jc1 patch I've
submitted since I left Cygnus over 18 months ago ... I do have a couple
sun-submitted verifier patches.)
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list