From: Paul Thomas Date: Wed, 29 Feb 2012 07:21:38 +0000 (+0000) Subject: re PR fortran/52386 (ICE in gfc_conv_descriptor_dtyp (realloc LHS related)) X-Git-Tag: releases/gcc-4.7.0~156 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5cda350e60df32b728d1cf4a346a980d5870193c;p=thirdparty%2Fgcc.git re PR fortran/52386 (ICE in gfc_conv_descriptor_dtyp (realloc LHS related)) 2012-02-29 Paul Thomas PR fortran/52386 * trans-expr.c (fcncall_realloc_result): Dereference the descriptor if needed. 2012-02-29 Paul Thomas PR fortran/52386 * gfortran.dg/realloc_on_assign_13.f90 : New test. From-SVN: r184651 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index babf8b56c822..48670876a394 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-02-29 Paul Thomas + + PR fortran/52386 + * trans-expr.c (fcncall_realloc_result): Dereference the + descriptor if needed. + 2012-02-22 Tobias Burnus PR fortran/52335 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index ec218384b760..3552da36be8b 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6299,6 +6299,8 @@ fcncall_realloc_result (gfc_se *se, int rank) /* Use the allocation done by the library. Substitute the lhs descriptor with a copy, whose data field is nulled.*/ desc = build_fold_indirect_ref_loc (input_location, se->expr); + if (POINTER_TYPE_P (TREE_TYPE (desc))) + desc = build_fold_indirect_ref_loc (input_location, desc); /* Unallocated, the descriptor does not have a dtype. */ tmp = gfc_conv_descriptor_dtype (desc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d835796bff0d..5ff3cd837ab8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-29 Paul Thomas + + PR fortran/52386 + * gfortran.dg/realloc_on_assign_13.f90 : New test. + 2012-02-28 Matthew Gretton-Dann PR target/51534 diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_13.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_13.f90 new file mode 100644 index 000000000000..9661d724f5b6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_13.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! Test the fix for PR52386. +! +! Contributed by Juergen Reuter +! +module cascades + implicit none + private +contains + function reduced (array) + integer, dimension(:), allocatable :: reduced + integer, dimension(:), intent(in) :: array + logical, dimension(size(array)) :: mask + mask = .true. + allocate (reduced (count (mask))) + reduced = pack (array, mask) + end function reduced +end module cascades +! { dg-final { cleanup-modules "cascades" } } +