------- Comment #11 from kargl at gcc dot gnu dot org 2009-11-15 18:38 ------- Jerry, I added
@@ -56,11 +55,11 @@ get_array_index (gfc_array_ref *ar, mpz_ for (i = 0; i < ar->dimen; i++) { e = gfc_copy_expr (ar->start[i]); - re = gfc_simplify_expr (e, 1); + gfc_simplify_expr (e, 1); if ((gfc_is_constant_expr (ar->as->lower[i]) == 0) || (gfc_is_constant_expr (ar->as->upper[i]) == 0) - || (gfc_is_constant_expr (e) == 0)) + /*|| (gfc_is_constant_expr (e) == 0)*/) gfc_error ("non-constant array in DATA statement %L", &ar->where); @@ -313,6 +314,10 @@ gfc_assign_data_value (gfc_expr *lvalue, else mpz_set (offset, index); +gmp_printf ("offset: %Zd\n", offset); +if (lvalue->ts.type == BT_DERIVED) + mpz_add_ui (offset, offset, 1); + in data.c to see the computed offset values. The first chunk comments out a check for a constant ar->start[] value, so that I get back to where get_data_index is called. For this code implicit none type :: a real :: x(3) end type a integer, parameter :: n = 3 type(a) :: b(n) real, parameter :: d1(3) = (/1., 2., 3./) real, parameter :: d2(3) = (/4., 5., 6./) real, parameter :: d3(3) = (/7., 8., 9./) integer :: i, z(n) data (b(i), i = 1, n) /a(d1), a(d2), a(d3)/ data (z(i), i = 1, n) / 1, 2, 3/ print *, z(1), b(1) print *, z(2), b(2) print *, z(3), b(3) end I get REMOVE:kargl[248] gfc4x -o z pr41807.f90 offset: 0 offset: 1 offset: 2 offset: 0 offset: -1 offset: -1 REMOVE:kargl[249] ./z 1 7.0000000 8.0000000 9.0000000 2 1.0000000 2.0000000 3.0000000 3 0.0000000 0.0000000 0.0000000 The first 3 offset values is from the data statement for the z(3) array. The next 3 are for the array b(3) of the derived type a. My conclusion to this point is that the array spec for an array of a derived type is not properly set, or we're looking at the wrong array spec. -- kargl at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sgk at troutmask dot apl dot | |washington dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41807