Commit 808a6ead by Jose Rui Faustino de Sousa Committed by Thomas König

For assumed-size arrays check if the reference is to a full array.

2020-04-22  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

	PR fortran/90350
	* simplify.c (simplify_bound): In the case of assumed-size arrays
	check if the reference is to a full array.

2020-04-22  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

	PR fortran/90350
	* gfortran.dg/PR90350.f90: New test.
parent 183e9006
2020-04-22 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/90350
* simplify.c (simplify_bound): In the case of assumed-size arrays
check if the reference is to a full array.
2020-04-22 Tobias Burnus <tobias@codesourcery.com>
PR fortran/94709
......
......@@ -4157,6 +4157,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
{
gfc_ref *ref;
gfc_array_spec *as;
ar_type type = AR_UNKNOWN;
int d;
if (array->ts.type == BT_CLASS)
......@@ -4180,6 +4181,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
switch (ref->type)
{
case REF_ARRAY:
type = ref->u.ar.type;
switch (ref->u.ar.type)
{
case AR_ELEMENT:
......@@ -4233,7 +4235,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
int k;
/* UBOUND(ARRAY) is not valid for an assumed-size array. */
if (upper && as && as->type == AS_ASSUMED_SIZE)
if (upper && type == AR_FULL && as && as->type == AS_ASSUMED_SIZE)
{
/* An error message will be emitted in
check_assumed_size_reference (resolve.c). */
......
2020-04-22 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/90350
* gfortran.dg/PR90350.f90: New test.
2020-04-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90448
......
! { dg-do compile }
!
! Test the fix for PR90350
!
! Contributed by <urbanjost@comcast.net>
!
program artificial
implicit none
integer :: arr(-10:10)
call asub(arr,size(arr))
end program artificial
subroutine asub(arr,n)
integer,intent(in) :: arr(*)
integer,intent(in) :: n
write(*,*)'UPPER=',ubound(arr(:n))
write(*,*)'LOWER=',lbound(arr(:n))
write(*,*)'SIZE=',size(arr(:n))
end subroutine asub
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment