]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/25031 ([4.1 only] Allocatable array can be reallocated.)
authorThomas Koenig <Thomas.Koenig@online.de>
Thu, 30 Mar 2006 16:30:26 +0000 (16:30 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 30 Mar 2006 16:30:26 +0000 (16:30 +0000)
2006-03-30  Thomas Koenig  <Thomas.Koenig@online.de>

PR fortran/25031
* runtime/memory.c (allocate_array):  If stat is present and
the variable is already allocated, free the variable, do
the allocation and set stat.
(allocate_array_64):  Likewise.  Whitespace fix.

2006-03-30  Thomas Koenig  <Thomas.Koenig@online.de>

PR fortran/25031
* gfortran.dg/multiple_allocation_1.f90:  Check that the
size has changed after a re-allocation with stat.

From-SVN: r112539

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/multiple_allocation_1.f90
libgfortran/ChangeLog
libgfortran/runtime/memory.c

index 53f2522df471d136a8d62c3dab44c8380ed7549d..018e11c93d0513509977cb55bccedcd4d13ba354 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-30  Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR fortran/25031
+       * gfortran.dg/multiple_allocation_1.f90:  Check that the
+       size has changed after a re-allocation with stat.
+
 2006-03-30  Richard Guenther  <rguenther@suse.de>
 
        * gcc.target/i386/sselibm-1.c: Adjust for libgcc-math partial
index 9c14248a05d69740567aed70f1900c7e52da0f5c..2b913734e478f170f823f562761792b9b7f553cf 100644 (file)
@@ -8,10 +8,11 @@ program alloc_test
   integer, pointer :: b(:)
 
   allocate(a(4))
-  ! This should set the stat code without changing the size
-  allocate(a(4),stat=i)
+  ! This should set the stat code and change the size.
+  allocate(a(3),stat=i)
   if (i == 0) call abort
   if (.not. allocated(a)) call abort
+  if (size(a) /= 3) call abort
   ! It's OK to allocate pointers twice (even though this causes
   ! a memory leak)
   allocate(b(4))
index c671337b7f292622c7e1a766bec8a96912632443..d082c073e6470b92fb527f288c5bf43405ce8882 100644 (file)
@@ -1,3 +1,11 @@
+2006-03-30  Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR fortran/25031
+       * runtime/memory.c (allocate_array):  If stat is present and
+       the variable is already allocated, free the variable, do
+       the allocation and set stat.
+       (allocate_array_64):  Likewise.  Whitespace fix.
+
 2006-03-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/26880
index 34d70f2f17b0c9fcb5e13bff0cef6712e0448f80..db55a552168e322dd1134016f5be90b6f9012514 100644 (file)
@@ -249,7 +249,12 @@ allocate_array (void **mem, GFC_INTEGER_4 size, GFC_INTEGER_4 * stat)
       return;
     }
   if (stat)
-    *stat = ERROR_ALLOCATION;
+    {
+      free (*mem);
+      allocate (mem, size, stat);
+      *stat = ERROR_ALLOCATION;
+      return;
+    }
   else
     runtime_error ("Attempting to allocate already allocated array.");
 
@@ -272,10 +277,15 @@ allocate64_array (void **mem, GFC_INTEGER_8 size, GFC_INTEGER_4 * stat)
       return;
     }
   if (stat)
-    *stat = ERROR_ALLOCATION;
+    {
+      free (*mem);
+      allocate (mem, size, stat);
+      *stat = ERROR_ALLOCATION;
+      return;
+    }
   else
     runtime_error ("Attempting to allocate already allocated array.");
-  
+
   return;
 }