From: Paul Thomas Date: Sat, 4 Apr 2009 14:47:23 +0000 (+0000) Subject: re PR fortran/39519 (bad assignment to type with allocatable component) X-Git-Tag: releases/gcc-4.3.4~241 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b945b59fa2c46391f234c8bcb980901354ca4ee2;p=thirdparty%2Fgcc.git re PR fortran/39519 (bad assignment to type with allocatable component) 2009-04-04 Paul Thomas PR fortran/39519 * parse.c (parse_derived): Do not break on finding pointer, allocatable or private components. 2009-04-04 Paul Thomas PR fortran/39519 * gfortran.dg/alloc_comp_assign_9.f90: New test. From-SVN: r145540 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9063d51ad8ce..f85b1d7e3ad3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-04-04 Paul Thomas + + PR fortran/39519 + * parse.c (parse_derived): Do not break on finding pointer, + allocatable or private components. + 2009-03-07 Paul Thomas PR fortran/39295 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index e21dc4f15430..fcaeb2389662 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1788,27 +1788,18 @@ parse_derived (void) /* Look for allocatable components. */ if (c->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->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->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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91d19668de88..890ac47d339c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-04 Paul Thomas + + PR fortran/39519 + * gfortran.dg/alloc_comp_assign_9.f90: New test. + 2009-04-02 David Ayers PR objc/18456 diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90 new file mode 100644 index 000000000000..9051bafa0198 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90 @@ -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 +! +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