This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix hack in trans-expr.c


This fixes the problems I have with LTO around this.  Just messing
with TYPE_MAIN_VARIANT compeltely messes up the variant chains.

Ok if bootstrap & testing passes?

Thanks,
Richard.

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

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

Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c	(revision 150772)
--- gcc/fortran/trans-expr.c	(working copy)
*************** gfc_trans_scalar_assign (gfc_se * lse, g
*** 4432,4460 ****
  	  gfc_add_expr_to_block (&block, 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));
      }
  
    gfc_add_block_to_block (&block, &lse->post);
--- 4432,4452 ----
  	  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);
  
        gfc_add_modify (&block, lse->expr,
! 		      fold_convert (TREE_TYPE (lse->expr), rse->expr));
      }
  
    gfc_add_block_to_block (&block, &lse->post);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]