From 16f681db1100e78ff9a0cb04fc8fd18719c92839 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Mon, 6 Nov 2017 09:54:09 +0000 Subject: [PATCH] [multiple changes] 2017-11-06 Paul Thomas 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 PR fortran/69739 * gfortran.dg/pr69739.f90: New test. From-SVN: r254441 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/trans-expr.c | 4 +-- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gfortran.dg/pr69739.f90 | 39 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr69739.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1e403366656..00448aa98b9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ + 2017-11-06 Paul Thomas + + PR fortran/69739 + * trans-expr.c (gfc_map_intrinsic_function): Return false for + bounds without the DIM argument instead of ICEing. + 2017-11-06 Martin Liska PR middle-end/82404 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 57b62a6b0c0..e4d45ac8d1d 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4178,9 +4178,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 fe5fcf48619..8232b4a4add 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-06 Paul Thomas + + PR fortran/69739 + * gfortran.dg/pr69739.f90: New test. + 2017-11-06 Martin Liska * c-c++-common/Wimplicit-fallthrough-8.c: Return a value for diff --git a/gcc/testsuite/gfortran.dg/pr69739.f90 b/gcc/testsuite/gfortran.dg/pr69739.f90 new file mode 100644 index 00000000000..f5e2359878e --- /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 -- 2.30.2