From: Harald Anlauf Date: Sun, 31 Mar 2019 18:33:51 +0000 (+0000) Subject: re PR fortran/83515 (ICE: Invalid expression in gfc_element_size) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=93755deb5c26a82106aa63280c492f9bda0679c2;p=gcc.git re PR fortran/83515 (ICE: Invalid expression in gfc_element_size) 2019-03-31 Harald Anlauf PR fortran/83515 PR fortran/85797 * trans-types.c (gfc_typenode_for_spec): Handle conversion for procedure pointers. * target-memory.c (gfc_element_size): Handle size determination for procedure pointers. PR fortran/83515 PR fortran/85797 * gfortran.dg/pr85797.f90: New test. From-SVN: r270045 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e80033a7d4e..61eb67b8b9a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2019-03-31 Harald Anlauf + + PR fortran/83515 + PR fortran/85797 + * trans-types.c (gfc_typenode_for_spec): Handle conversion for + procedure pointers. + * target-memory.c (gfc_element_size): Handle size determination + for procedure pointers. + 2019-03-31 Thomas Koenig * dump-parse-tree.c (debug): Add for symbol_attribute *, diff --git a/gcc/fortran/target-memory.c b/gcc/fortran/target-memory.c index 09af2a56818..1354c577ece 100644 --- a/gcc/fortran/target-memory.c +++ b/gcc/fortran/target-memory.c @@ -120,6 +120,7 @@ gfc_element_size (gfc_expr *e, size_t *siz) case BT_CLASS: case BT_VOID: case BT_ASSUMED: + case BT_PROCEDURE: { /* Determine type size without clobbering the typespec for ISO C binding types. */ diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 9ae516bb666..22410b551e6 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1194,6 +1194,9 @@ gfc_typenode_for_spec (gfc_typespec * spec, int codim) basetype = pfunc_type_node; } break; + case BT_PROCEDURE: + basetype = pfunc_type_node; + break; default: gcc_unreachable (); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2377b1a4cb7..3c173b5b726 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-03-31 Harald Anlauf + + PR fortran/83515 + PR fortran/85797 + * gfortran.dg/pr85797.f90: New test. + 2019-03-31 Rainer Orth * gcc.dg/attr-aligned-3.c: Enable on *-*-solaris2.*. diff --git a/gcc/testsuite/gfortran.dg/pr85797.f90 b/gcc/testsuite/gfortran.dg/pr85797.f90 new file mode 100644 index 00000000000..fe6d96d6e30 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85797.f90 @@ -0,0 +1,33 @@ +! { 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 + +subroutine a + c = transfer (a, b) ! { dg-warning "Non-RECURSIVE procedure" } +end + +recursive subroutine d + c = transfer (d, b) +end + +recursive subroutine e + k = transfer (transfer (e, e), 1) +end + +subroutine f + use, intrinsic :: iso_c_binding + integer(c_intptr_t) :: b, c + c = transfer (transfer (b, a), b) +end + +module m +contains + function f () result (z) ! { dg-warning "Return value" } + class(*), pointer :: z + end function f + recursive subroutine s (q) + procedure(f) :: q + call s (q) + end subroutine s +end