From: Harald Anlauf Date: Tue, 24 Jan 2023 20:39:43 +0000 (+0100) Subject: Fortran: ICE in transformational_result [PR108529] X-Git-Tag: releases/gcc-10.5.0~294 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b66a0f2fecb4dc1ac5960ff5d630ab8f672b4106;p=thirdparty%2Fgcc.git Fortran: ICE in transformational_result [PR108529] gcc/fortran/ChangeLog: PR fortran/108529 * simplify.c (simplify_transformation): Do not try to simplify transformational intrinsic when the ARRAY argument has a NULL shape. gcc/testsuite/ChangeLog: PR fortran/108529 * gfortran.dg/pr108529.f90: New test. (cherry picked from commit 6c96382eed96a9285611f2e3e2e59557094172b8) --- diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index c1db8650b0d5..fe4fee897f05 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -676,6 +676,7 @@ simplify_transformation (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, size_zero = gfc_is_size_zero_array (array); if (!(is_constant_array_expr (array) || size_zero) + || array->shape == NULL || !gfc_is_constant_expr (dim)) return NULL; diff --git a/gcc/testsuite/gfortran.dg/pr108529.f90 b/gcc/testsuite/gfortran.dg/pr108529.f90 new file mode 100644 index 000000000000..34c9691fae13 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr108529.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/108529 - ICE in transformational_result +! Contributed by G.Steinmetz + +program p + integer, parameter :: a(*,*) = reshape([1, 2, 3, 4], [2, 2]) + logical, parameter :: b(2,*) = a > 2 ! { dg-error "Assumed size" } + logical, parameter :: c(*) = all(b, 1) ! { dg-error "Bad shape" } +end