re PR fortran/89904 (ICE in gfortran starting with r270045)

2019-04-04  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/89004
	* check.c (gfc_check_transfer): Reject procedures as actual
	arguments for SOURCE and MOLD of TRANSFER intrinsic.

	PR fortran/89004
	* gfortran.dg/pr85797.f90: Adjust testcase.

From-SVN: r270150
This commit is contained in:
Harald Anlauf 2019-04-04 20:38:33 +00:00 committed by Harald Anlauf
parent 3a36c1806a
commit aace91e285
4 changed files with 40 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2019-04-04 Harald Anlauf <anlauf@gmx.de>
PR fortran/89004
* check.c (gfc_check_transfer): Reject procedures as actual
arguments for SOURCE and MOLD of TRANSFER intrinsic.
2019-04-03 Steven G. Kargl <kargl@gcc.gnu.org> 2019-04-03 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68567 PR fortran/68567

View File

@ -5544,6 +5544,26 @@ gfc_check_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size)
size_t source_size; size_t source_size;
size_t result_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) if (mold->ts.type == BT_HOLLERITH)
{ {
gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L must not be" gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L must not be"
@ -5551,6 +5571,8 @@ gfc_check_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size)
return false; return false;
} }
/* SIZE (optional) shall be an integer scalar. The corresponding actual
argument shall not be an optional dummy argument. */
if (size != NULL) if (size != NULL)
{ {
if (!type_check (size, 2, BT_INTEGER)) if (!type_check (size, 2, BT_INTEGER))

View File

@ -1,3 +1,8 @@
2019-04-04 Harald Anlauf <anlauf@gmx.de>
PR fortran/89004
* gfortran.dg/pr85797.f90: Adjust testcase.
2019-04-04 Paolo Carlini <paolo.carlini@oracle.com> 2019-04-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65619 PR c++/65619

View File

@ -1,29 +1,27 @@
! { dg-do compile } ! { dg-do compile }
! { dg-options "-Wall" }
! PR fortran/83515 - ICE: Invalid expression in gfc_element_size ! 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/85797 - ICE in gfc_element_size, at fortran/target-memory.c:126
! PR fortran/89904 - ICE in gfortran starting with r270045
subroutine a recursive subroutine a
c = transfer (a, b) ! { dg-warning "Non-RECURSIVE procedure" } c = transfer (a, b) ! { dg-error "'SOURCE' argument of 'TRANSFER'" }
end end
recursive subroutine d 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 end
subroutine f subroutine f
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(c_intptr_t) :: b, c integer(c_intptr_t) :: b, c
procedure(), pointer :: a
c = transfer (a, b)
c = transfer (transfer (b, a), b) c = transfer (transfer (b, a), b)
end end
module m module m
contains contains
function f () result (z) ! { dg-warning "Return value" } function f () result (z)
class(*), pointer :: z class(*), pointer :: z
end function f end function f
recursive subroutine s (q) recursive subroutine s (q)