diff options
author | dcarrera <dcarrera@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-27 10:10:06 +0000 |
---|---|---|
committer | dcarrera <dcarrera@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-27 10:10:06 +0000 |
commit | 297effe4a0af07893bba126c94f447e91da63474 (patch) | |
tree | 0ce63aa3e4271ca28e6a80ffa44834d9407308ed /gcc/testsuite | |
parent | f5038a769921a53cfaddee7f4fd3668f4d48d849 (diff) | |
download | gcc-297effe4a0af07893bba126c94f447e91da63474.tar.gz |
2011-07-26 Daniel Carrera <dcarrera@gmail.com>
PR fortran/49755
* trans.c (gfc_allocate_using_malloc): Change function signature.
Return nothing. New parameter "pointer". Eliminate temorary variables.
(gfc_allocate_using_lib): Ditto.
(gfc_allocate_allocatable): Ditto. Update call to gfc_allocate_using_lib
and gfc_allocate_using_malloc. Do not free and then reallocate a
variable that is already allocated.
(gfc_likely): New function. Basedon gfc_unlikely.
* trans-array.c (gfc_array_init_size): New parameter "descriptor_block".
Instructions to modify the array descriptor are stored in this block
while other instructions continue to be stored in "pblock".
(gfc_array_allocate): Update call to gfc_array_init_size. Move the
descriptor_block so that the array descriptor is only updated if
the array was allocated successfully.
Update calls to gfc_allocate_allocatable and gfc_allocate_using_malloc.
* trans.h (gfc_allocate_allocatable): Change function signature.
Function now returns void.
(gfc_allocate_using_lib): Ditto, and new function parameter.
(gfc_allocate_using_malloc): Ditto.
* trans-openmp.c (gfc_omp_clause_default_ctor,
gfc_omp_clause_copy_ctor,gfc_trans_omp_array_reduction): Replace a call
to gfc_allocate_allocatable with gfc_allocate_using_malloc.
* trans-stmt.c (gfc_trans_allocate): Update function calls for
gfc_allocate_allocatable and gfc_allocate_using_malloc.
2011-07-26 Daniel Carrera <dcarrera@gmail.com>
PR fortran/49755
* gfortran.dg/multiple_allocation_1.f90: Fix test. Allocating an
allocated array should *not* change its size.
* gfortran.dg/multiple_allocation_3.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176822 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 | 7 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/multiple_allocation_3.f90 | 19 |
3 files changed, 31 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f0cb44b5167..a1df3d19816 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-07-27 Daniel Carrera <dcarrera@gmail.com> + + PR fortran/49755 + * gfortran.dg/multiple_allocation_1.f90: Fix test. Allocating an + allocated array should *not* change its size. + * gfortran.dg/multiple_allocation_3.f90: New test. + 2011-07-26 Paolo Carlini <paolo.carlini@oracle.com> PR c++/49776 diff --git a/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 b/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 index 2b913734e47..58888f0e31b 100644 --- a/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 +++ b/gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 @@ -1,6 +1,8 @@ ! { dg-do run } ! PR 25031 - We didn't cause an error when allocating an already ! allocated array. +! +! This testcase has been modified to fix PR 49755. program alloc_test implicit none integer :: i @@ -8,11 +10,12 @@ program alloc_test integer, pointer :: b(:) allocate(a(4)) - ! This should set the stat code and change the size. + ! This should set the stat code but not 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 + if (size(a) /= 4) call abort + ! It's OK to allocate pointers twice (even though this causes ! a memory leak) allocate(b(4)) diff --git a/gcc/testsuite/gfortran.dg/multiple_allocation_3.f90 b/gcc/testsuite/gfortran.dg/multiple_allocation_3.f90 new file mode 100644 index 00000000000..482b388a4d5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/multiple_allocation_3.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! PR 49755 - If allocating an already allocated array, and stat= +! is given, set stat to non zero and do not touch the array. +program test + integer, allocatable :: A(:, :) + integer :: stat + + allocate(A(20,20)) + A = 42 + + ! Allocate of already allocated variable + allocate (A(5,5), stat=stat) + + ! Expected: Error stat and previous allocation status + if (stat == 0) call abort () + if (any (shape (A) /= [20, 20])) call abort () + if (any (A /= 42)) call abort () +end program + |