From: Paul Thomas Date: Mon, 6 Nov 2017 11:48:32 +0000 (+0000) Subject: backport: re PR fortran/69739 (ICE during array result, allocatable assignment) X-Git-Tag: releases/gcc-6.5.0~697 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=566fe453f5a044875b4868083b6148a2382bcd03;p=thirdparty%2Fgcc.git backport: re PR fortran/69739 (ICE during array result, allocatable assignment) 2017-11-06 Paul Thomas Backported from trunk PR fortran/69739 * trans-expr.c (gfc_map_intrinsic_function): Return false for bounds without the DIM argument instead of ICEing. 2017-11-06 Paul Thomas Backported from trunk PR fortran/69739 * gfortran.dg/pr69739.f90: New test. From-SVN: r254448 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ae8a9faa478c..bc8c8bbf323a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-11-06 Paul Thomas + + Backported from trunk + PR fortran/69739 + * trans-expr.c (gfc_map_intrinsic_function): Return false for + bounds without the DIM argument instead of ICEing. + 2017-11-01 Steven G. Kargl PR fortran/82796 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index c899d639741a..f1b7bfd9d6b1 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4150,9 +4150,7 @@ gfc_map_intrinsic_function (gfc_expr *expr, gfc_interface_mapping *mapping) if (arg2 && arg2->expr_type == EXPR_CONSTANT) d = mpz_get_si (arg2->value.integer) - 1; else - /* TODO: If the need arises, this could produce an array of - ubound/lbounds. */ - gcc_unreachable (); + return false; if (expr->value.function.isym->id == GFC_ISYM_LBOUND) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b8b8e6c1cb5..baab709cee50 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-11-06 Paul Thomas + + Backported from trunk + PR fortran/69739 + * gfortran.dg/pr69739.f90: New test. + 2017-11-01 Steven G. Kargl PR fortran/82796 diff --git a/gcc/testsuite/gfortran.dg/pr69739.f90 b/gcc/testsuite/gfortran.dg/pr69739.f90 new file mode 100644 index 000000000000..f5e2359878ee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69739.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! +! Test the fix for PR69739 in which the statement +! R = operate(A, X) caused an ICE. +! +! Contributed by John +! +module test + + implicit none + type, public :: sometype + real :: a = 0. + end type +contains + + function dosomething(A) result(r) + type(sometype), intent(IN) :: A(:,:,:) + integer :: N + real, allocatable :: R(:), X(:) + + N = PRODUCT(UBOUND(A)) + allocate (R(N),X(N)) + X = [(real(N), N = 1, size(X, 1))] + R = operate(A, X) + end function + + function operate(A, X) + type(sometype), intent(IN) :: A(:,:,:) + real, intent(IN) :: X(:) + real :: operate(1:PRODUCT(UBOUND(A))) + + operate = x + end function +end module test + + use test + type(sometype) :: a(2, 2, 2) + if (any(int (dosomething(a)) .ne. [1,2,3,4,5,6])) call abort +end