2020-8-21 Steve Kargl <sgk@troutmask.apl.washington.edu>

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  <jrfsousa@gmail.com>

gcc/testsuite/ChangeLog:

	* gfortran.dg/PR95352.f90: New test.
This commit is contained in:
Steve Kargl 2020-08-30 17:48:12 +00:00 committed by José Rui Faustino de Sousa
parent 8e1be7efcb
commit cd49b70678
2 changed files with 28 additions and 1 deletions

View File

@ -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]);

View File

@ -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