From cf3f7b309ffdd888fdd85048ac9b4bcdc2713a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6nig?= Date: Sat, 25 Apr 2020 12:28:15 +0200 Subject: Fix PR 94578. Our intrinsics do not handle spans on their return values (yet), so this creates a temporary for subref array pointers. 2020-04-25 Thomas Koenig PR fortran/94578 * trans-expr.c (arrayfunc_assign_needs_temporary): If the LHS is a subref pointer, we also need a temporary. 2020-04-25 Thomas Koenig PR fortran/94578 * gfortran.dg/pointer_assign_14.f90: New test. * gfortran.dg/pointer_assign_15.f90: New test. --- gcc/fortran/trans-expr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index fdca9cc..030edc1 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -9823,9 +9823,13 @@ arrayfunc_assign_needs_temporary (gfc_expr * expr1, gfc_expr * expr2) /* If we have reached here with an intrinsic function, we do not need a temporary except in the particular case that reallocation - on assignment is active and the lhs is allocatable and a target. */ + on assignment is active and the lhs is allocatable and a target, + or a pointer which may be a subref pointer. FIXME: The last + condition can go away when we use span in the intrinsics + directly.*/ if (expr2->value.function.isym) - return (flag_realloc_lhs && sym->attr.allocatable && sym->attr.target); + return (flag_realloc_lhs && sym->attr.allocatable && sym->attr.target) + || (sym->attr.pointer && sym->attr.subref_array_pointer); /* If the LHS is a dummy, we need a temporary if it is not INTENT(OUT). */ -- cgit v1.1