+2019-08-13 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/90561
+ * trans.h (gfc_evaluate_now_function_scope): New function.
+ * trans.c (gfc_evaluate_now_function_scope): New function.
+ * trans-expr.c (gfc_trans_assignment): Use it.
+
2019-08-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89647
- resolve.c (resolve_typebound_procedure): Allow host associated
+ resolve.c (resolve_typebound_procedure): Allow host associated
procedure to be a binding target. While here, wrap long line.
2019-08-13 Steven G. Kargl <kargl@gcc.gnu.org>
if (expr1->ts.deferred
&& gfc_expr_attr (expr1).allocatable
&& gfc_check_dependency (expr1, expr2, true))
- rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
+ rse.string_length =
+ gfc_evaluate_now_function_scope (rse.string_length, &rse.pre);
string_length = rse.string_length;
}
else
return gfc_evaluate_now_loc (input_location, expr, pblock);
}
+/* Like gfc_evaluate_now, but add the created variable to the
+ function scope. */
+
+tree
+gfc_evaluate_now_function_scope (tree expr, stmtblock_t * pblock)
+{
+ tree var;
+ var = gfc_create_var_np (TREE_TYPE (expr), NULL);
+ gfc_add_decl_to_function (var);
+ gfc_add_modify (pblock, var, expr);
+
+ return var;
+}
/* Build a MODIFY_EXPR node and add it to a given statement block PBLOCK.
A MODIFY_EXPR is an assignment:
/* If the value is not constant, Create a temporary and copy the value. */
tree gfc_evaluate_now_loc (location_t, tree, stmtblock_t *);
tree gfc_evaluate_now (tree, stmtblock_t *);
+tree gfc_evaluate_now_function_scope (tree, stmtblock_t *);
/* Find the appropriate variant of a math intrinsic. */
tree gfc_builtin_decl_for_float_kind (enum built_in_function, int);
+2019-08-13 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/90561
+ * gfortran.dg/deferred_character_34.f90: New test.
+
2019-08-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89647
--- /dev/null
+! { dg-do run }
+! PR fortran/90561
+! This used to ICE.
+! Original test case by Gerhard Steinmetz.
+program p
+ character(:), allocatable :: z(:)
+ z = [character(2):: 'ab', 'xy']
+ z = z(2)
+ if (any(z /= 'xy')) stop 1
+end