re PR fortran/39519 (bad assignment to type with allocatable component)

2009-04-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39519
	* parse.c (parse_derived): Do not break on finding pointer,
	allocatable or private components.

2009-04-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39519
	* gfortran.dg/alloc_comp_assign_9.f90: New test.

From-SVN: r145538
This commit is contained in:
Paul Thomas 2009-04-04 13:19:15 +00:00
parent 1e07c3d97b
commit 155165cf69
4 changed files with 36 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2009-04-04 Paul Thomas <pault@gcc.gnu.org>
Backport from mainline:
PR fortran/39519
* parse.c (parse_derived): Do not break on finding pointer,
allocatable or private components.
2009-04-03 Tobias Burnus <burnus@net-b.de>
PR fortran/39594

View File

@ -1978,27 +1978,18 @@ endType:
/* Look for allocatable components. */
if (c->attr.allocatable
|| (c->ts.type == BT_DERIVED && c->ts.derived->attr.alloc_comp))
{
sym->attr.alloc_comp = 1;
break;
}
sym->attr.alloc_comp = 1;
/* Look for pointer components. */
if (c->attr.pointer
|| (c->ts.type == BT_DERIVED && c->ts.derived->attr.pointer_comp))
{
sym->attr.pointer_comp = 1;
break;
}
sym->attr.pointer_comp = 1;
/* Look for private components. */
if (sym->component_access == ACCESS_PRIVATE
|| c->attr.access == ACCESS_PRIVATE
|| (c->ts.type == BT_DERIVED && c->ts.derived->attr.private_comp))
{
sym->attr.private_comp = 1;
break;
}
sym->attr.private_comp = 1;
}
if (!seen_component)

View File

@ -1,3 +1,9 @@
2009-04-04 Paul Thomas <pault@gcc.gnu.org>
Backport from mainline:
PR fortran/39519
* gfortran.dg/alloc_comp_assign_9.f90: New test.
2009-04-03 H.J. Lu <hongjiu.lu@intel.com>
Backport from mainline:

View File

@ -0,0 +1,20 @@
! { dg-do run }
! Test the fix for PR39519, where the presence of the pointer
! as the first component was preventing the second from passing
! the "alloc_comp" attribute to the derived type.
!
! Contributed by Gilbert Scott <gilbert.scott@easynet.co.uk>
!
PROGRAM X
TYPE T
INTEGER, POINTER :: P
INTEGER, ALLOCATABLE :: A(:)
END TYPE T
TYPE(T) :: T1,T2
ALLOCATE ( T1%A(1) )
ALLOCATE ( T2%A(1) )
T1%A = 23
T2 = T1
T1%A = 42
if (T2%A(1) .NE. 23) CALL ABORT
END PROGRAM X