From patchwork Fri Aug 24 15:12:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [fortran, 5/5] PR 45586: Use the right type in scalar to array assignments Date: Fri, 24 Aug 2012 05:12:54 -0000 From: Mikael Morin X-Patchwork-Id: 179861 Message-Id: <20120824151026.6294.48823@marvin> To: gfortran , GCC patches Patch number 3 handled scalar assignments like: scalar_some_type = some_type(...) Patch number 4 handled array assignments like: array_some_type = (/some_type :: .../) This takes care of assignments like: array_some_type = some_type(...) i.e. scalar to array assignments. As all the infrastructure has been installed previously, this simply sets it up properly. OK? 2012-08-22 Mikael Morin * trans-array.c (gfc_add_loop_ss_code): Use RESTRICTED field. * trans-expr.c (gfc_trans_assignment): Set RESTRICTED field. diff --git a/trans-array.c b/trans-array.c index f5051ff..432fc72 100644 --- a/trans-array.c +++ b/trans-array.c @@ -2489,6 +2489,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, /* Scalar expression. Evaluate this now. This includes elemental dimension indices, but not array section bounds. */ gfc_init_se (&se, NULL); + se.want_restricted_types = ss_info->restricted; gfc_conv_expr (&se, expr); gfc_add_block_to_block (&outer_loop->pre, &se.pre); diff --git a/trans-expr.c b/trans-expr.c index 2a60087..6af753a 100644 --- a/trans-expr.c +++ b/trans-expr.c @@ -7258,8 +7258,11 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, /* Walk the rhs. */ rss = gfc_walk_expr (expr2); if (rss == gfc_ss_terminator) - /* The rhs is scalar. Add a ss for the expression. */ - rss = gfc_get_scalar_ss (gfc_ss_terminator, expr2); + { + /* The rhs is scalar. Add a ss for the expression. */ + rss = gfc_get_scalar_ss (gfc_ss_terminator, expr2); + gfc_ss_set_restricted (rss, !gfc_expr_attr (expr1).target); + } else if (rss->next == gfc_ss_terminator && rss->info->type == GFC_SS_CONSTRUCTOR) gfc_ss_set_restricted (rss, !(gfc_expr_attr (expr1).target));