trans-expr.c (gfc_trans_scalar_assign): Replace hack with more proper hack.
authorRichard Guenther <rguenther@suse.de>
Sun, 16 Aug 2009 22:36:13 +0000 (22:36 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sun, 16 Aug 2009 22:36:13 +0000 (22:36 +0000)
2009-08-17  Richard Guenther  <rguenther@suse.de>

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

From-SVN: r150817

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c

index 8ed5945..694e02f 100644 (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
index 51593e7..144c204 100644 (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);