This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] for PR 19362


Hello,

while the two types t0 in the testcase are identical from the point of
view of fortran (I hope, I am no fortran expert), they are represented
as two distinct types internally.  This causes ICE in
gfc_trans_scalar_assign when emitting the assignment and casting rhs of
the assignment to lhs, since fold_convert cannot convert aggregate
types.

To fix the problem, the patch makes the function to add
VIEW_CONVERT_EXPR in case the assigned types differ and
they are aggregates.

Bootstrapped & regtested on i686.

Zdenek

	PR fortran/19362
	* trans-expr.c (gfc_trans_scalar_assign): Add VIEW_CONVERT_EXPR
	for aggregates if the types differ.

Index: fortran/trans-expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-expr.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 trans-expr.c
*** fortran/trans-expr.c	3 Jan 2005 21:43:55 -0000	1.34
--- fortran/trans-expr.c	13 Jan 2005 09:42:28 -0000
*************** gfc_trans_scalar_assign (gfc_se * lse, g
*** 2014,2024 ****
      }
    else
      {
        gfc_add_block_to_block (&block, &lse->pre);
        gfc_add_block_to_block (&block, &rse->pre);
  
!       gfc_add_modify_expr (&block, lse->expr,
! 			   fold_convert (TREE_TYPE (lse->expr), rse->expr));
      }
  
    gfc_add_block_to_block (&block, &lse->post);
--- 2014,2035 ----
      }
    else
      {
+       tree rse_expr, ltype;
+ 
        gfc_add_block_to_block (&block, &lse->pre);
        gfc_add_block_to_block (&block, &rse->pre);
  
!       rse_expr = rse->expr;
!       ltype = TREE_TYPE (lse->expr);
!       if (ltype != TREE_TYPE (rse_expr))
! 	{
! 	  if (AGGREGATE_TYPE_P (ltype))
! 	    rse_expr = build1 (VIEW_CONVERT_EXPR, ltype, rse_expr);
! 	  else
! 	    rse_expr = fold_convert (ltype, rse_expr);
! 	}
! 
!       gfc_add_modify_expr (&block, 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]