This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: Patch to fix the PR #108.
- To: egcs-patches at egcs dot cygnus dot com
- Subject: [PATCH] Java: Patch to fix the PR #108.
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Tue, 7 Mar 2000 14:10:30 -0800
- Reply-to: apbianco at redhat dot com
I committed this patch in order to fix the PR #108:
http://sourceware.cygnus.com/ml/java-prs/1999-q4/msg00174.html
./A
2000-03-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
* java-tree.h (IS_INIT_CHECKED): New flag.
* check-init.c (check_init): Test and set IS_INIT_CHECKED.
* 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: check-init.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/check-init.c,v
retrieving revision 1.18
diff -u -p -r1.18 check-init.c
--- check-init.c 2000/02/26 05:12:27 1.18
+++ check-init.c 2000/03/07 22:04:00
@@ -611,7 +611,6 @@ check_init (exp, before)
case FIX_TRUNC_EXPR:
case INDIRECT_REF:
case ADDR_EXPR:
- case SAVE_EXPR:
case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
@@ -619,6 +618,13 @@ check_init (exp, before)
case NON_LVALUE_EXPR:
case INSTANCEOF_EXPR:
/* Avoid needless recursion. */
+ exp = TREE_OPERAND (exp, 0);
+ goto again;
+
+ case SAVE_EXPR:
+ if (IS_INIT_CHECKED (exp))
+ return;
+ IS_INIT_CHECKED (exp) = 1;
exp = TREE_OPERAND (exp, 0);
goto again;
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/expr.c,v
retrieving revision 1.64
diff -u -p -r1.64 expr.c
--- expr.c 2000/03/07 11:41:22 1.64
+++ expr.c 2000/03/07 22:04:06
@@ -2749,7 +2749,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;
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.58
diff -u -p -r1.58 java-tree.h
--- java-tree.h 2000/03/07 08:58:26 1.58
+++ java-tree.h 2000/03/07 22:04:09
@@ -58,6 +58,7 @@ struct JCF;
5: HAS_BEEN_ALREADY_PARSED_P (in IDENTIFIER_NODE)
IS_BREAK_STMT_P (in EXPR_WITH_FILE_LOCATION)
IS_CRAFTED_STRING_BUFFER_P (in CALL_EXPR)
+ IS_INIT_CHECKED (in SAVE_EXPR)
6: CAN_COMPLETE_NORMALLY (in statement nodes).
Usage of TYPE_LANG_FLAG_?:
@@ -868,6 +869,10 @@ extern tree *type_map;
/* True if EXPR (a CALL_EXPR in that case) is a crafted StringBuffer */
#define IS_CRAFTED_STRING_BUFFER_P(EXPR) TREE_LANG_FLAG_5 (EXPR)
+
+/* True if EXPR (a SAVE_EXPR in that case) had its content already
+ checked for (un)initialized local variables. */
+#define IS_INIT_CHECKED(EXPR) TREE_LANG_FLAG_5 (EXPR)
/* If set in CALL_EXPR, the receiver is 'super'. */
#define CALL_USING_SUPER(EXPR) TREE_LANG_FLAG_4 (EXPR)
Index: parse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.c,v
retrieving revision 1.126
diff -u -p -r1.126 parse.c
--- parse.c 2000/03/07 18:46:22 1.126
+++ parse.c 2000/03/07 22:04:47
@@ -12963,6 +12963,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: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.139
diff -u -p -r1.139 parse.y
--- parse.y 2000/03/07 11:41:32 1.139
+++ parse.y 2000/03/07 22:05:15
@@ -10273,6 +10273,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;