trans-expr.c (gfc_trans_scalar_assign): Replace hack with more proper hack.

2009-08-17  Richard Guenther  <rguenther@suse.de>

	* trans-expr.c (gfc_trans_scalar_assign): Replace hack with
	more proper hack.

From-SVN: r150817
This commit is contained in:
Richard Guenther 2009-08-16 22:36:13 +00:00 committed by Richard Biener
parent a6494e5388
commit fbe7af45be
2 changed files with 14 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2009-08-17 Richard Guenther <rguenther@suse.de>
* trans-expr.c (gfc_trans_scalar_assign): Replace hack with
more proper hack.
2009-08-15 Tobias Burnus <burnus@net-b.de>
PR fortran/41080

View File

@ -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);