From: Janus Weil Date: Sat, 25 Aug 2018 15:41:34 +0000 (+0200) Subject: re PR fortran/86545 (ICE in transfer_expr on invalid WRITE statement) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d6fc627f6cb78ecf280622c05eed59e9150a5c7;p=gcc.git re PR fortran/86545 (ICE in transfer_expr on invalid WRITE statement) fix PR 86545 2018-08-25 Janus Weil PR fortran/86545 * resolve.c (resolve_transfer): Correctly determine typespec for generic function calls, in order to throw a proper error. 2018-08-25 Janus Weil PR fortran/86545 * gfortran.dg/generic_35.f90: New test case. From-SVN: r263854 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0d81a496017..22c40527bc6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-08-25 Janus Weil + + PR fortran/86545 + * resolve.c (resolve_transfer): Correctly determine typespec for + generic function calls, in order to throw a proper error. + 2018-08-24 Thomas Koenig PR fortran/86837 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 43a8470e748..ded27624283 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9280,7 +9280,6 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) static void resolve_transfer (gfc_code *code) { - gfc_typespec *ts; gfc_symbol *sym, *derived; gfc_ref *ref; gfc_expr *exp; @@ -9316,7 +9315,9 @@ resolve_transfer (gfc_code *code) _("item in READ"))) return; - ts = exp->expr_type == EXPR_STRUCTURE ? &exp->ts : &exp->symtree->n.sym->ts; + const gfc_typespec *ts = exp->expr_type == EXPR_STRUCTURE + || exp->expr_type == EXPR_FUNCTION + ? &exp->ts : &exp->symtree->n.sym->ts; /* Go to actual component transferred. */ for (ref = exp->ref; ref; ref = ref->next) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da37cb11d26..13601d2de3b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-25 Janus Weil + + PR fortran/86545 + * gfortran.dg/generic_35.f90: New test case. + 2018-08-24 David Malcolm PR 87091 diff --git a/gcc/testsuite/gfortran.dg/generic_35.f90 b/gcc/testsuite/gfortran.dg/generic_35.f90 new file mode 100644 index 00000000000..24ac270319f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/generic_35.f90 @@ -0,0 +1,31 @@ +! { dg-do compile } +! +! PR 86545: ICE in transfer_expr on invalid WRITE statement +! +! Contributed by Janus Weil + +module m + + type tString + character(len=:), allocatable :: cs + end type + + interface my_trim + module procedure trim_string + end interface + +contains + + elemental function trim_string(self) result(str) + type(tString) :: str + class(tString), intent(in) :: self + end function + +end module + + +program p + use m + type(tString) :: s + write(*,*) my_trim(s) ! { dg-error "cannot have ALLOCATABLE components" } +end