[Patch, fortran] PR29098 - allocation of a pointer to a derived type crashes
Paul Thomas
paulthomas2@wanadoo.fr
Sun Oct 1 13:50:00 GMT 2006
Ping!
http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00671.html
This is required for the allocatable components patch - if you look
carefully at the last version, posted on PR20541, you will see that it
is there. I would rather that this is OK'd in its own right.
Paul
> :ADDPATCH fortran:
>
> In the end, I took a third option to fix this PR:
>
> Ultimately, the failure to resolve the actual argument list was
> occurring in resolve.c(resolve_structure_cons). This was returning
> FAILURE on finding a NULL expression. I have been unable to think of
> any situation where this is warranted, nor I have generated bad code
> that gets clobbered by this. Also, in translation, empty expressions
> are correctly treated, by the same continuation to the next
> component. The testcase is that provided by the reporter.
>
> It should be noted that in trying to break this patch, I generated
> PR29115. *sigh*
>
> Regtested on FC5/Athlon - OK for trunk and 4.1?
>
> Paul
>
> 2006-09-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/29098
> * resolve.c (resolve_structure_cons): Do not return FAILURE if
> component expression is NULL.
>
> 2006-09-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/29098
> * gfortran.dg/default_initialization_2.f90: New test.
>
>
>
>
> ------------------------------------------------------------------------
>
> Index: gcc/fortran/resolve.c
> ===================================================================
> *** gcc/fortran/resolve.c (revision 116991)
> --- gcc/fortran/resolve.c (working copy)
> *************** resolve_structure_cons (gfc_expr * expr)
> *** 597,606 ****
> for (; comp; comp = comp->next, cons = cons->next)
> {
> if (! cons->expr)
> ! {
> ! t = FAILURE;
> ! continue;
> ! }
>
> if (gfc_resolve_expr (cons->expr) == FAILURE)
> {
> --- 597,603 ----
> for (; comp; comp = comp->next, cons = cons->next)
> {
> if (! cons->expr)
> ! continue;
>
> if (gfc_resolve_expr (cons->expr) == FAILURE)
> {
> Index: gcc/testsuite/gfortran.dg/default_initialization_2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/default_initialization_2.f90 (revision 0)
> --- gcc/testsuite/gfortran.dg/default_initialization_2.f90 (revision 0)
> ***************
> *** 0 ****
> --- 1,36 ----
> + ! { dg-do compile }
> + ! This tests the patch for PR29098, in which the presence of the default
> + ! initializer would cause allocate to fail because the latter uses
> + ! the interface assignment. This, in its turn was failing because
> + ! no expressions were found for the other components; and a FAILURE
> + ! was returned from resolve_structure_cons.
> + !
> + ! Contributed by Olav Vahtras <vahtras@pdc.kth.se>
> + !
> + MODULE MAT
> + TYPE BAS
> + INTEGER :: R = 0,C = 0
> + END TYPE BAS
> + TYPE BLOCK
> + INTEGER, DIMENSION(:), POINTER :: R,C
> + TYPE(BAS), POINTER, DIMENSION(:) :: NO => NULL()
> + END TYPE BLOCK
> + INTERFACE ASSIGNMENT(=)
> + MODULE PROCEDURE BLASSIGN
> + END INTERFACE
> + CONTAINS
> + SUBROUTINE BLASSIGN(A,B)
> + TYPE(BLOCK), INTENT(IN) :: B
> + TYPE(BLOCK), INTENT(INOUT) :: A
> + INTEGER I,N
> + ! ...
> + END SUBROUTINE BLASSIGN
> + END MODULE MAT
> + PROGRAM TEST
> + USE MAT
> + TYPE(BLOCK) MATRIX
> + POINTER MATRIX
> + ALLOCATE(MATRIX)
> + END
> +
> + ! { dg-final { cleanup-modules "mat" } }
>
>
> ------------------------------------------------------------------------
>
> 2006-09-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/29098
> * resolve.c (resolve_structure_cons): Do not return FAILURE if
> component expression is NULL.
>
> 2006-09-17 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/29098
> * gfortran.dg/default_initialization_2.f90: New test.
More information about the Fortran
mailing list