OSDN Git Service

2006-10-14 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 14 Oct 2006 13:09:56 +0000 (13:09 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 14 Oct 2006 13:09:56 +0000 (13:09 +0000)
PR fortran/29371
* trans-expr.c (gfc_trans_pointer_assignment): Add the expression
for the assignment of null to the data field to se->pre, rather
than block.

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

PR fortran/29371
* gfortran.dg/nullify_3.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117732 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/nullify_3.f90 [new file with mode: 0644]

index c487767..910de0d 100644 (file)
@@ -1,3 +1,10 @@
+2006-10-14 Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/29371
+       * trans-expr.c (gfc_trans_pointer_assignment): Add the expression
+       for the assignment of null to the data field to se->pre, rather
+       than block.     
+
 2006-10-14  Kazu Hirata  <kazu@codesourcery.com>
 
        * intrinsic.texi: Fix typos.
index 875092f..190a115 100644 (file)
@@ -3149,7 +3149,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
        {
        case EXPR_NULL:
          /* Just set the data pointer to null.  */
-         gfc_conv_descriptor_data_set (&block, lse.expr, null_pointer_node);
+         gfc_conv_descriptor_data_set (&lse.pre, lse.expr, null_pointer_node);
          break;
 
        case EXPR_VARIABLE:
index dbdd789..075f175 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-14 Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/29371
+       * gfortran.dg/nullify_3.f90: New test.
+
 2006-10-14  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/pthread-init-2.c (dg-options): Define _POSIX_C_SOURCE=199506L
diff --git a/gcc/testsuite/gfortran.dg/nullify_3.f90 b/gcc/testsuite/gfortran.dg/nullify_3.f90
new file mode 100644 (file)
index 0000000..7d202a2
--- /dev/null
@@ -0,0 +1,26 @@
+! { dg-do run }
+! { dg-options "-O0 -fbounds-check" }
+! Tests patch for PR29371, in which the null pointer
+! assignment would cause a segfault with the bounds
+! check on.
+!
+! Contributed by Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
+!
+program test
+  implicit none
+  type projector_t
+    real,   pointer :: ket(:, :), bra(:, :)
+  end type projector_t
+
+  type(projector_t),pointer, dimension(:) :: p
+  integer :: stat,i
+  allocate(p(2),stat=stat)
+  do i = 1, 2
+        nullify(p(i)%bra)
+        nullify(p(i)%ket)
+  end do
+  do i = 1, 2
+        if (associated (p(i)%bra)) call abort ()
+        if (associated (p(i)%ket)) call abort ()
+  end do
+end program