From fbe7af45beb2fe70468ed772d448def8ff098e5e Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sun, 16 Aug 2009 22:36:13 +0000 Subject: [PATCH] trans-expr.c (gfc_trans_scalar_assign): Replace hack with more proper hack. 2009-08-17 Richard Guenther * trans-expr.c (gfc_trans_scalar_assign): Replace hack with more proper hack. From-SVN: r150817 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/trans-expr.c | 26 +++++++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8ed59457483f..694e02f89a9b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2009-08-17 Richard Guenther + + * trans-expr.c (gfc_trans_scalar_assign): Replace hack with + more proper hack. + 2009-08-15 Tobias Burnus PR fortran/41080 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 51593e7ae19d..144c20441e93 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4432,29 +4432,21 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts, gfc_add_expr_to_block (&block, tmp); } } + else if (ts.type == BT_DERIVED) + { + gfc_add_block_to_block (&block, &lse->pre); + gfc_add_block_to_block (&block, &rse->pre); + tmp = gfc_evaluate_now (rse->expr, &block); + tmp = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lse->expr), rse->expr); + gfc_add_modify (&block, lse->expr, tmp); + } else { gfc_add_block_to_block (&block, &lse->pre); gfc_add_block_to_block (&block, &rse->pre); - /* TODO This is rather obviously the wrong place to do this. - However, a number of testcases, such as function_kinds_1 - and function_types_2 fail without it, by ICEing at - fold_const: 2710 (fold_convert_loc). */ - if (ts.type == BT_DERIVED - && gfc_option.flag_whole_file - && (TYPE_MAIN_VARIANT (TREE_TYPE (rse->expr)) - != TYPE_MAIN_VARIANT (TREE_TYPE (lse->expr)))) - { - tmp = gfc_evaluate_now (rse->expr, &block); - TYPE_MAIN_VARIANT (TREE_TYPE (tmp)) - = TYPE_MAIN_VARIANT (TREE_TYPE (lse->expr)); - } - else - tmp = rse->expr; - gfc_add_modify (&block, lse->expr, - fold_convert (TREE_TYPE (lse->expr), tmp)); + fold_convert (TREE_TYPE (lse->expr), rse->expr)); } gfc_add_block_to_block (&block, &lse->post); -- 2.43.5