From: Steve Kargl Date: Sun, 30 Aug 2020 17:48:12 +0000 (+0000) Subject: 2020-8-21 Steve Kargl X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cd49b7067893b548a10c99ea0cb6aba2977eef2e;p=gcc.git 2020-8-21 Steve Kargl gcc/fortran/ChangeLog: PR fortran/95352 * simplify.c (simplify_bound_dim): Add check for NULL pointer before trying to access structure member. José Rui Faustino de Sousa gcc/testsuite/ChangeLog: * gfortran.dg/PR95352.f90: New test. --- diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 8e0d2f97a60..bfd410cf31d 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4080,7 +4080,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper, || (coarray && d == as->rank + as->corank && (!upper || flag_coarray == GFC_FCOARRAY_SINGLE))) { - if (as->lower[d-1]->expr_type == EXPR_CONSTANT) + if (as->lower[d-1] && as->lower[d-1]->expr_type == EXPR_CONSTANT) { gfc_free_expr (result); return gfc_copy_expr (as->lower[d-1]); diff --git a/gcc/testsuite/gfortran.dg/PR95352.f90 b/gcc/testsuite/gfortran.dg/PR95352.f90 new file mode 100644 index 00000000000..20c81675212 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR95352.f90 @@ -0,0 +1,27 @@ +! { dg-do compile } +! +! Test the fix for PR95352 +! + +module ice6_m + + implicit none + +contains + + function ice6_s(a) result(ierr) + integer, intent(in) :: a(..) + + integer :: ierr + + integer :: lb + + select rank(a) + rank(*) + lb = lbound(a, dim=1) + if(lbound(a, dim=1)/=lb) ierr = -1 + end select + return + end function ice6_s + +end module ice6_m