Commit 6b86a9bc by Thomas Koenig Committed by Thomas Koenig

re PR fortran/25031 ([4.1 only] Allocatable array can be reallocated.)

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
parent c7ec5472
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> 2006-03-30 Richard Guenther <rguenther@suse.de>
* gcc.target/i386/sselibm-1.c: Adjust for libgcc-math partial * gcc.target/i386/sselibm-1.c: Adjust for libgcc-math partial
...@@ -8,10 +8,11 @@ program alloc_test ...@@ -8,10 +8,11 @@ program alloc_test
integer, pointer :: b(:) integer, pointer :: b(:)
allocate(a(4)) allocate(a(4))
! This should set the stat code without changing the size ! This should set the stat code and change the size.
allocate(a(4),stat=i) allocate(a(3),stat=i)
if (i == 0) call abort if (i == 0) call abort
if (.not. allocated(a)) 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 ! It's OK to allocate pointers twice (even though this causes
! a memory leak) ! a memory leak)
allocate(b(4)) allocate(b(4))
......
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> 2006-03-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/26880 PR libgfortran/26880
......
...@@ -249,7 +249,12 @@ allocate_array (void **mem, GFC_INTEGER_4 size, GFC_INTEGER_4 * stat) ...@@ -249,7 +249,12 @@ allocate_array (void **mem, GFC_INTEGER_4 size, GFC_INTEGER_4 * stat)
return; return;
} }
if (stat) if (stat)
*stat = ERROR_ALLOCATION; {
free (*mem);
allocate (mem, size, stat);
*stat = ERROR_ALLOCATION;
return;
}
else else
runtime_error ("Attempting to allocate already allocated array."); runtime_error ("Attempting to allocate already allocated array.");
...@@ -272,10 +277,15 @@ allocate64_array (void **mem, GFC_INTEGER_8 size, GFC_INTEGER_4 * stat) ...@@ -272,10 +277,15 @@ allocate64_array (void **mem, GFC_INTEGER_8 size, GFC_INTEGER_4 * stat)
return; return;
} }
if (stat) if (stat)
*stat = ERROR_ALLOCATION; {
free (*mem);
allocate (mem, size, stat);
*stat = ERROR_ALLOCATION;
return;
}
else else
runtime_error ("Attempting to allocate already allocated array."); runtime_error ("Attempting to allocate already allocated array.");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment