Index: gdb/dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.156 diff -c -p -r1.156 dwarf2read.c *** gdb/dwarf2read.c 6 Jul 2004 19:29:30 -0000 1.156 --- gdb/dwarf2read.c 28 Jul 2004 13:03:05 -0000 *************** read_array_type (struct die_info *die, s *** 3718,3726 **** /* Dwarf2 dimensions are output from left to right, create the necessary array types in backwards order. */ type = element_type; ! while (ndim-- > 0) ! type = create_array_type (NULL, type, range_types[ndim]); /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the --- 3720,3751 ---- /* Dwarf2 dimensions are output from left to right, create the necessary array types in backwards order. */ + + /* Take account of array ordering, if possible. */ type = element_type; ! ! attr = dwarf2_attr (die, DW_AT_ordering, cu); ! ! /* Trust this attribute if present. If not, assume col-major for FORTRAN ! unless the compiler is GNU F77 which puts things the opposite way to the ! dwarf2 spec. ! ! FIXME: dsl/2004-07-20: If G77 is ever fixed by checking version string of ! producer. ! */ ! if ((attr && (DW_SND(attr) == DW_ORD_col_major)) ! || (!attr && ( cu->language == language_fortran && ! ( !cu->producer || !strstr(cu->producer, "GNU F77" ))))) ! { ! int i = 0; ! while (i < ndim) ! type = create_array_type (NULL, type, range_types[i++]); ! } ! else ! { ! while (ndim-- > 0) ! type = create_array_type (NULL, type, range_types[ndim]); ! } /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the Index: gdb/eval.c =================================================================== RCS file: /cvs/src/src/gdb/eval.c,v retrieving revision 1.41 diff -c -p -r1.41 eval.c *** gdb/eval.c 8 Apr 2004 21:18:12 -0000 1.41 --- gdb/eval.c 28 Jul 2004 13:03:07 -0000 *************** evaluate_subexp_standard (struct type *e *** 1610,1618 **** multi_f77_subscript: { ! int subscript_array[MAX_FORTRAN_DIMS + 1]; /* 1-based array of ! subscripts, max == 7 */ ! int array_size_array[MAX_FORTRAN_DIMS + 1]; int ndimensions = 1, i; struct type *tmp_type; int offset_item; /* The array offset where the item lives */ --- 1610,1617 ---- multi_f77_subscript: { ! int subscript_array[MAX_FORTRAN_DIMS]; ! int array_size_array[MAX_FORTRAN_DIMS]; int ndimensions = 1, i; struct type *tmp_type; int offset_item; /* The array offset where the item lives */ *************** evaluate_subexp_standard (struct type *e *** 1630,1636 **** let us actually find out where this element exists in the array. */ offset_item = 0; ! for (i = 1; i <= nargs; i++) { /* Evaluate each subscript, It must be a legal integer in F77 */ arg2 = evaluate_subexp_with_coercion (exp, pos, noside); --- 1629,1636 ---- let us actually find out where this element exists in the array. */ offset_item = 0; ! /* Take array indices left to right */ ! for (i = 0; i < nargs; i++) { /* Evaluate each subscript, It must be a legal integer in F77 */ arg2 = evaluate_subexp_with_coercion (exp, pos, noside); *************** evaluate_subexp_standard (struct type *e *** 1638,1644 **** --- 1638,1648 ---- /* Fill in the subscript and array size arrays */ subscript_array[i] = value_as_long (arg2); + } + /* Internal type of array is arranged right to left */ + for (i = 0; i < nargs; i++) + { retcode = f77_get_dynamic_upperbound (tmp_type, &upper); if (retcode == BOUND_FETCH_ERROR) error ("Cannot obtain dynamic upper bound"); *************** evaluate_subexp_standard (struct type *e *** 1647,1657 **** if (retcode == BOUND_FETCH_ERROR) error ("Cannot obtain dynamic lower bound"); ! array_size_array[i] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ ! subscript_array[i] -= lower; /* If we are at the bottom of a multidimensional array type then keep a ptr to the last ARRAY --- 1651,1661 ---- if (retcode == BOUND_FETCH_ERROR) error ("Cannot obtain dynamic lower bound"); ! array_size_array[nargs - i - 1] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ ! subscript_array[nargs - i - 1] -= lower; /* If we are at the bottom of a multidimensional array type then keep a ptr to the last ARRAY *************** evaluate_subexp_standard (struct type *e *** 1661,1677 **** of base element type that we apply a simple offset to. */ ! if (i < nargs) tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } /* Now let us calculate the offset for this item */ ! offset_item = subscript_array[ndimensions]; ! for (i = ndimensions - 1; i >= 1; i--) offset_item = ! array_size_array[i] * offset_item + subscript_array[i]; /* Construct a value node with the value of the offset */ --- 1665,1681 ---- of base element type that we apply a simple offset to. */ ! if (i < nargs - 1) tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } /* Now let us calculate the offset for this item */ ! offset_item = subscript_array[ndimensions - 1]; ! for (i = ndimensions - 1; i > 0; --i) offset_item = ! array_size_array[i - 1] * offset_item + subscript_array[i - 1]; /* Construct a value node with the value of the offset */