On 07/26/2011 10:11 PM, Daniel Carrera wrote:
The attached patch fixes PR 49755, allowing GFortran to behave correctly when faced with multiple allocations:
Ok for trunk?

        * trans-array.c (gfc_array_init_size): New parameter "desciptor_block".

Typo: desc(r)iptor_block.

        * trans-openmp.c (gfc_omp_clause_default_ctor): Replace a call to
        gfc_allocate_allocatable with gfc_allocate_using_malloc.
        (gfc_omp_clause_copy_ctor): Ditto.
        (gfc_trans_omp_array_reduction): Ditto.

You can combine changes different functions in a single file as in

    * trans-openmp.c (gfc_omp_clause_default_ctor,
    gfc_omp_clause_copy_ctor, gfc_trans_omp_array_reduction): ...

        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. Tests PR 49755.

The "Tests PR 49755." is redundant as one already has "PR fortran/49755".



Your patch does *not* compile for me as you missed to add gfc_likely to trans.h:

gcc/fortran/trans-array.c:4554:4: error: 'gfc_likely' was not declared in this scope


Index: gcc/testsuite/gfortran.dg/multiple_allocation_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 (revision 176622)
+++ gcc/testsuite/gfortran.dg/multiple_allocation_1.f90 (working copy)
@@ -10,3 +10,3 @@ program alloc_test
    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)

For later reference, I would prefer to add a comment stating that the testcase has been modified to fix PR 49755. It's not really needed but sometimes convenient to go back to all PRs which were involved in creating/modifying the test case.

Otherwise, the patch is OK.

Tobias

Reply via email to