diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9147a22cf47..f64e743aff9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2005-07-31 Steven Bosscher + + * trans-stmt.c (gfc_trans_goto): Jump to the known label instead + of the assigned goto variable. + 2005-07-29 Steven Bosscher * trans-types.h (gfc_array_range_type): Add missing GTY decl for this. diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 99467b4945f..72407ae4425 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -163,11 +163,11 @@ gfc_trans_goto (gfc_code * code) gfc_trans_runtime_check (tmp, assign_error, &se.pre); assigned_goto = GFC_DECL_ASSIGN_ADDR (se.expr); - target = build1 (GOTO_EXPR, void_type_node, assigned_goto); code = code->block; if (code == NULL) { + target = build1 (GOTO_EXPR, void_type_node, assigned_goto); gfc_add_expr_to_block (&se.pre, target); return gfc_finish_block (&se.pre); } @@ -177,10 +177,12 @@ gfc_trans_goto (gfc_code * code) do { - tmp = gfc_get_label_decl (code->label); - tmp = gfc_build_addr_expr (pvoid_type_node, tmp); + target = gfc_get_label_decl (code->label); + tmp = gfc_build_addr_expr (pvoid_type_node, target); tmp = build2 (EQ_EXPR, boolean_type_node, tmp, assigned_goto); - tmp = build3_v (COND_EXPR, tmp, target, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, tmp, + build1 (GOTO_EXPR, void_type_node, target), + build_empty_stmt ()); gfc_add_expr_to_block (&se.pre, tmp); code = code->block; }