aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/parse.c
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1998-12-23 02:46:45 -0800
committerPer Bothner <bothner@gcc.gnu.org>1998-12-23 02:46:45 -0800
commit5a005d9ead24d081423f620a84da54d4a260b001 (patch)
treed2caa4d11dd4417a98a74be6e8b0a49a2e9c6768 /gcc/java/parse.c
parente402ca989ba0d54124f90b6a95cc595e272f7919 (diff)
downloadgcc-5a005d9ead24d081423f620a84da54d4a260b001.zip
gcc-5a005d9ead24d081423f620a84da54d4a260b001.tar.gz
gcc-5a005d9ead24d081423f620a84da54d4a260b001.tar.bz2
expr.c (process_jvm_instruction): Do load_type_state after JSR.
d * expr.c (process_jvm_instruction): Do load_type_state after JSR. * verify.c (verify_jvm_instructions): Fix off-by-one error. * jcf-write.c (CHECK_PUT): Add (void) cast to avoid -Wall warnings. (localvar_alloc): Change return type to void, (emit_unop): Remove unused variable size. * jcf-write.c (struct jcf_block): Add new union. (PENDING_CLEANUP_PC, PENDING_EXIT_PC, UNDEFINED_PC): New macros. (call_cleanups): New functions. (struct jcf_partial): New fields num_finalizers and return_value_decl. (generate_bytecode_insns): Support CLEANUP_POINT_EXPR and WITH_CLEANUP_EXPR. Handle cleanups in RETURN_EXPR and EXIT_BLOCK_EXPR. * lang.c (lang_init): Call using_eh_for_cleanups. * parse.y (java_complete_lhs): For SYNCHRONIZED_EXPR, defer completing operands to patch_synchronized_statement. Support CLEANUP_POINT_EXPR, WITH_CLEANUP_EXPR. (patch_synchronized_statement): Re-write suing CLEANUP_POINT_EXPR and WITH_CLEANUP_EXPR instead of TRY_EXPR. From-SVN: r24406
Diffstat (limited to 'gcc/java/parse.c')
-rw-r--r--gcc/java/parse.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/gcc/java/parse.c b/gcc/java/parse.c
index 9230323..1b6c71a 100644
--- a/gcc/java/parse.c
+++ b/gcc/java/parse.c
@@ -2272,7 +2272,7 @@ static const short yycheck[] = { 3,
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@@ -10129,13 +10129,24 @@ java_complete_lhs (node)
case SYNCHRONIZED_EXPR:
wfl_op1 = TREE_OPERAND (node, 0);
- COMPLETE_CHECK_OP_0 (node);
- COMPLETE_CHECK_OP_1 (node);
return patch_synchronized_statement (node, wfl_op1);
case TRY_EXPR:
return patch_try_statement (node);
+ case CLEANUP_POINT_EXPR:
+ COMPLETE_CHECK_OP_0 (node);
+ TREE_TYPE (node) = void_type_node;
+ CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
+ return node;
+
+ case WITH_CLEANUP_EXPR:
+ COMPLETE_CHECK_OP_0 (node);
+ COMPLETE_CHECK_OP_2 (node);
+ CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
+ TREE_TYPE (node) = void_type_node;
+ return node;
+
case LABELED_BLOCK_EXPR:
PUSH_LABELED_BLOCK (node);
if (LABELED_BLOCK_BODY (node))
@@ -13378,12 +13389,19 @@ static tree
patch_synchronized_statement (node, wfl_op1)
tree node, wfl_op1;
{
- tree expr = TREE_OPERAND (node, 0);
+ tree expr = java_complete_tree (TREE_OPERAND (node, 0));
tree block = TREE_OPERAND (node, 1);
- tree try_block, catch_all, stmt, compound, decl;
+
+ tree enter, exit, finally, expr_decl;
+
+ if (expr == error_mark_node)
+ {
+ block = java_complete_tree (block);
+ return expr;
+ }
/* The TYPE of expr must be a reference type */
- if (!JREFERENCE_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 0))))
+ if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
{
SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
parse_error_context (wfl_operator, "Incompatible type for `synchronized'"
@@ -13409,34 +13427,23 @@ patch_synchronized_statement (node, wfl_op1)
Throw (e);
} */
- /* TRY block */
- BUILD_MONITOR_ENTER (stmt, expr);
- compound = add_stmt_to_compound (NULL_TREE, int_type_node, stmt);
- compound = add_stmt_to_compound (compound, void_type_node, block);
- if (CAN_COMPLETE_NORMALLY (block))
- {
- BUILD_MONITOR_EXIT (stmt, expr);
- compound = add_stmt_to_compound (compound, int_type_node, stmt);
- }
- try_block = build_expr_block (compound, NULL_TREE);
- CAN_COMPLETE_NORMALLY (try_block) = CAN_COMPLETE_NORMALLY (block);
-
- /* CATCH_ALL block */
- decl = build_decl (VAR_DECL, generate_name (), ptr_type_node);
- BUILD_ASSIGN_EXCEPTION_INFO (stmt, decl);
- compound = add_stmt_to_compound (NULL_TREE, void_type_node, stmt);
- BUILD_MONITOR_EXIT (stmt, expr);
- compound = add_stmt_to_compound (compound, int_type_node, stmt);
- BUILD_THROW (stmt, decl);
- compound = add_stmt_to_compound (compound, void_type_node, stmt);
- catch_all = build_expr_block (compound, decl);
- catch_all = build_expr_block (catch_all, NULL_TREE);
- catch_all = build1 (CATCH_EXPR, void_type_node, catch_all);
-
- /* TRY-CATCH statement */
- compound = build (TRY_EXPR, void_type_node, try_block, catch_all, NULL_TREE);
- CAN_COMPLETE_NORMALLY (compound) = CAN_COMPLETE_NORMALLY (try_block);
- return compound;
+ expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
+ BUILD_MONITOR_ENTER (enter, expr_decl);
+ BUILD_MONITOR_EXIT (exit, expr_decl);
+ CAN_COMPLETE_NORMALLY (enter) = 1;
+ CAN_COMPLETE_NORMALLY (exit) = 1;
+ node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
+ build (COMPOUND_EXPR, NULL_TREE,
+ build (WITH_CLEANUP_EXPR, NULL_TREE,
+ build (COMPOUND_EXPR, NULL_TREE,
+ build (MODIFY_EXPR, NULL_TREE,
+ expr_decl, expr),
+ enter),
+ NULL_TREE, exit),
+ block));
+ node = build_expr_block (node, expr_decl);
+
+ return java_complete_tree (node);
}
/* 14.16 The throw Statement */
@@ -13764,7 +13771,7 @@ fold_constant_for_init (node, context)
if (val == NULL_TREE || ! TREE_CONSTANT (val))
return NULL_TREE;
TREE_OPERAND (node, 0) = val;
- node = patch_unaryop (node, op0);
+ return patch_unaryop (node, op0);
break;
case COND_EXPR: