re PR fortran/29098 (allocation of a pointer to a derived type crashes)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 4 Oct 2006 04:48:35 +0000 (04:48 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 4 Oct 2006 04:48:35 +0000 (04:48 +0000)
2006-10-04  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/29098
* resolve.c (resolve_structure_cons): Do not return FAILURE if
component expression is NULL.

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

PR fortran/29098
* gfortran.dg/default_initialization_2.f90: New test.

From-SVN: r117424

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/default_initialization_2.f90 [new file with mode: 0644]

index ea011dca7e4777972a0d291ec9717882ed901476..548a3d9cf981098cb0e2816632fca05828abb4e5 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-04  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/29098
+       * resolve.c (resolve_structure_cons): Do not return FAILURE if
+       component expression is NULL.
+
 2006-10-03  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/20779
index 7639eb737e10ba4da5d8321b563637662847dd92..e28a93cbcdfe9083fab5842d522d64e03be54028 100644 (file)
@@ -607,10 +607,7 @@ resolve_structure_cons (gfc_expr * expr)
   for (; comp; comp = comp->next, cons = cons->next)
     {
       if (! cons->expr)
-       {
-         t = FAILURE;
-         continue;
-       }
+       continue;
 
       if (gfc_resolve_expr (cons->expr) == FAILURE)
        {
index ea575ee0d1872c200f74f63cf1d99c2ba1da0aae..7cc0dd29aa7cfd3120ca4d1b7da4ecfedd21c0a7 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-04  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/29098
+       * gfortran.dg/default_initialization_2.f90: New test.
+
 2006-10-03  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/20779
diff --git a/gcc/testsuite/gfortran.dg/default_initialization_2.f90 b/gcc/testsuite/gfortran.dg/default_initialization_2.f90
new file mode 100644 (file)
index 0000000..cc7ecdc
--- /dev/null
@@ -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" } }