This is the mail archive of the gcc-bugs@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]

[Bug fortran/49213] [OOP] gfortran rejects structure constructor expression


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213

--- Comment #10 from janus at gcc dot gnu.org 2013-01-10 20:39:58 UTC ---
The following patch makes comment 8 and 9 compile, but I'm not sure if the
generated code is correct:

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 194927)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -5990,23 +5990,11 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp
       gfc_add_expr_to_block (&block, tmp);
     }
     }
-  else if (expr->ts.type == BT_DERIVED)
+  else if (expr->ts.type == BT_DERIVED && expr->expr_type == EXPR_STRUCTURE)
     {
-      if (expr->expr_type != EXPR_STRUCTURE)
-    {
-      gfc_init_se (&se, NULL);
-      gfc_conv_expr (&se, expr);
-      gfc_add_block_to_block (&block, &se.pre);
-      gfc_add_modify (&block, dest,
-                   fold_convert (TREE_TYPE (dest), se.expr));
-      gfc_add_block_to_block (&block, &se.post);
-    }
-      else
-    {
-      /* Nested constructors.  */
-      tmp = gfc_trans_structure_assign (dest, expr);
-      gfc_add_expr_to_block (&block, tmp);
-    }
+      /* Nested constructors.  */
+      tmp = gfc_trans_structure_assign (dest, expr);
+      gfc_add_expr_to_block (&block, tmp);
     }
   else
     {


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