re PR fortran/35470 (Valid pointer assigment code gives compilation errors)

2008-03-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/35470
	* resolve.c (check_assumed_size_reference):  Only visit the
	first reference and look directly at the highest dimension.

2008-03-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/35470
	* gfortran.dg/subref_array_pointer_3.f90 : New test.

From-SVN: r133279
This commit is contained in:
Paul Thomas 2008-03-16 19:14:17 +00:00
parent 41ff0d66b3
commit c52938ec21
4 changed files with 29 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2008-03-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/35470
* resolve.c (check_assumed_size_reference): Only visit the
first reference and look directly at the highest dimension.
2008-03-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35184

View File

@ -954,20 +954,12 @@ static int need_full_assumed_size = 0;
static bool
check_assumed_size_reference (gfc_symbol *sym, gfc_expr *e)
{
gfc_ref *ref;
int dim;
int last = 1;
if (need_full_assumed_size || !(sym->as && sym->as->type == AS_ASSUMED_SIZE))
return false;
for (ref = e->ref; ref; ref = ref->next)
if (ref->type == REF_ARRAY)
for (dim = 0; dim < ref->u.ar.as->rank; dim++)
last = (ref->u.ar.end[dim] == NULL)
&& (ref->u.ar.type == DIMEN_ELEMENT);
if (last)
if ((e->ref->u.ar.end[e->ref->u.ar.as->rank - 1] == NULL)
&& (e->ref->u.ar.as->type == AS_ASSUMED_SIZE)
&& (e->ref->u.ar.type == DIMEN_ELEMENT))
{
gfc_error ("The upper bound in the last dimension must "
"appear in the reference to the assumed size "

View File

@ -1,3 +1,8 @@
2008-03-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/35470
* gfortran.dg/subref_array_pointer_3.f90 : New test.
2008-03-16 Richard Guenther <rguenther@suse.de>
PR middle-end/35607

View File

@ -0,0 +1,15 @@
! { dg-do compile }
! Tests the fix for PR35470, in which the pointer assignment would fail
! because the assumed size 'arr' would get mixed up with the component
! 'p' in the check for the upper bound of an assumed size array.
!
! Contributed by Antony Lewis <antony@cosmologist.info>
!
subroutine sub(arr)
type real_pointer
real, pointer :: p(:)
end type real_pointer
type(real_pointer), dimension(*) :: arr
real, pointer :: p(:)
p => arr(1)%p
end subroutine