Hi all, attached patch fixes a regression that occurred on some testcases when doing a validation run with -frepack-arrays. The issue here was that for class arrays the array descriptor is in the _data component and not directly at the address of the class_array. The patch fixes this issue for pr69659 on trunk 7 and gcc-6-branch.
Ok for trunk and gcc-6? Bootstrapped and regtested on x86_64-linux-gnu. Regards, Andre -- Andre Vehreschild * Email: vehre ad gmx dot de
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 7be301d..403ce3a 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -6386,7 +6386,12 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, stmtCleanup = gfc_finish_block (&cleanup); /* Only do the cleanup if the array was repacked. */ - tmp = build_fold_indirect_ref_loc (input_location, dumdesc); + if (is_classarray) + /* For a class array the dummy array descriptor is in the _class + component. */ + tmp = gfc_class_data_get (dumdesc); + else + tmp = build_fold_indirect_ref_loc (input_location, dumdesc); tmp = gfc_conv_descriptor_data_get (tmp); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp, tmpdesc); diff --git a/gcc/testsuite/gfortran.dg/class_array_22.f03 b/gcc/testsuite/gfortran.dg/class_array_22.f03 new file mode 100644 index 0000000..9410741 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_array_22.f03 @@ -0,0 +1,25 @@ +! { dg-do compile } +! { dg-options "-frepack-arrays " } +! +! Original class_array_11.f03 but with -frepack-arrays a new +! ICE was produced reported in +! PR fortran/69659 +! +! Original testcase by Ian Harvey <ian_har...@bigpond.com> +! Reduced by Janus Weil <ja...@gcc.gnu.org> + + IMPLICIT NONE + + TYPE :: ParentVector + INTEGER :: a + END TYPE ParentVector + +CONTAINS + + SUBROUTINE vector_operation(pvec) + CLASS(ParentVector), INTENT(INOUT) :: pvec(:) + print *,pvec(1)%a + END SUBROUTINE + +END +
gcc/testsuite/ChangeLog: 2016-05-22 Andre Vehreschild <ve...@gcc.gnu.org> PR fortran/69659 * gfortran.dg/class_array_22.f03: New test. gcc/fortran/ChangeLog: 2016-05-22 Andre Vehreschild <ve...@gcc.gnu.org> PR fortran/69659 * trans-array.c (gfc_trans_dummy_array_bias): For class arrays use the address of the _data component to reference the arrays data component.