diff options
| author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-30 16:30:26 +0000 |
|---|---|---|
| committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-30 16:30:26 +0000 |
| commit | 1f8fb4716c48741ae1894d8597f41bd18751f8ef (patch) | |
| tree | ccefb2ba3589b346ff9e82de690b49f0e7f063c7 | |
| parent | 4dc5882f34be26e1e708c100304c53a3fd85daee (diff) | |
| download | ppe42-gcc-1f8fb4716c48741ae1894d8597f41bd18751f8ef.tar.gz ppe42-gcc-1f8fb4716c48741ae1894d8597f41bd18751f8ef.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112539 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 | 5 | ||||
| -rw-r--r-- | libgfortran/ChangeLog | 8 | ||||
| -rw-r--r-- | libgfortran/runtime/memory.c | 16 |
4 files changed, 30 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 53f2522df47..018e11c93d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 b/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 index 9c14248a05d..2b913734e47 100644 --- a/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 +++ b/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 @@ -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)) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index c671337b7f2..d082c073e64 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -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 diff --git a/libgfortran/runtime/memory.c b/libgfortran/runtime/memory.c index 34d70f2f17b..db55a552168 100644 --- a/libgfortran/runtime/memory.c +++ b/libgfortran/runtime/memory.c @@ -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; } |

