Dear all, my fix for pr85797 and pr83515 came along with a testcase that failed on powerpc64*-unknown-linux-gnu. It turned out that the checks for the arguments to the TRANSFER intrinsic had to be tightened, i.e. not to allow some of the tests. This patch revises the checks to a version as discussed in the PR, and adjusts the testcase accordingly.
Regtests cleanly on x86_64-pc-linux-gnu. Could someone with access to powerpc64*-unknown-linux-gnu please verify? (Thomas?) OK for trunk (and affected backports)? Thanks, Harald 2019-04-02 Harald Anlauf <anl...@gmx.de> PR fortran/89004 * check.c (gfc_check_transfer): Reject procedures as actual arguments for SOURCE and MOLD of TRANSFER intrinsic. 2019-04-02 Harald Anlauf <anl...@gmx.de> PR fortran/89004 * gfortran.dg/pr85797.f90: Adjust testcase.
Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 270047) +++ gcc/fortran/check.c (working copy) @@ -5544,6 +5544,26 @@ size_t source_size; size_t result_size; + /* SOURCE shall be a scalar or array of any type. */ + if (source->ts.type == BT_PROCEDURE + && source->symtree->n.sym->attr.subroutine == 1) + { + gfc_error ("%<SOURCE%> argument of %<TRANSFER%> intrinsic at %L " + "must not be a %s", &source->where, + gfc_basic_typename (source->ts.type)); + return false; + } + + /* MOLD shall be a scalar or array of any type. */ + if (mold->ts.type == BT_PROCEDURE + && mold->symtree->n.sym->attr.subroutine == 1) + { + gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L " + "must not be a %s", &mold->where, + gfc_basic_typename (mold->ts.type)); + return false; + } + if (mold->ts.type == BT_HOLLERITH) { gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L must not be" @@ -5551,6 +5571,8 @@ return false; } + /* SIZE (optional) shall be an integer scalar. The corresponding actual + argument shall not be an optional dummy argument. */ if (size != NULL) { if (!type_check (size, 2, BT_INTEGER))
Index: gcc/testsuite/gfortran.dg/pr85797.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85797.f90 (revision 270047) +++ gcc/testsuite/gfortran.dg/pr85797.f90 (working copy) @@ -1,29 +1,27 @@ ! { dg-do compile } -! { dg-options "-Wall" } ! PR fortran/83515 - ICE: Invalid expression in gfc_element_size ! PR fortran/85797 - ICE in gfc_element_size, at fortran/target-memory.c:126 +! PR fortran/89904 - ICE in gfortran starting with r270045 -subroutine a - c = transfer (a, b) ! { dg-warning "Non-RECURSIVE procedure" } +recursive subroutine a + c = transfer (a, b) ! { dg-error "'SOURCE' argument of 'TRANSFER'" } end recursive subroutine d - c = transfer (d, b) + c = transfer (b, d) ! { dg-error "'MOLD' argument of 'TRANSFER'" } end -recursive subroutine e - k = transfer (transfer (e, e), 1) -end - subroutine f use, intrinsic :: iso_c_binding integer(c_intptr_t) :: b, c + procedure(), pointer :: a + c = transfer (a, b) c = transfer (transfer (b, a), b) end module m contains - function f () result (z) ! { dg-warning "Return value" } + function f () result (z) class(*), pointer :: z end function f recursive subroutine s (q)