@@ -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);
@@ -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));