diff options
author | David Lecomber <david@lecomber.net> | 2004-08-29 10:12:24 +0000 |
---|---|---|
committer | David Lecomber <david@lecomber.net> | 2004-08-29 10:12:24 +0000 |
commit | 7ca2d3a37165b1847d70b4436d8b2d62d0d5fba7 (patch) | |
tree | fbe75dec9d20c099a13c1126dc1115ed85a87e49 /gdb/eval.c | |
parent | 47e35c11d6ece68ddf7069b36f20a6d6fbb7c465 (diff) | |
download | gdb-7ca2d3a37165b1847d70b4436d8b2d62d0d5fba7.zip gdb-7ca2d3a37165b1847d70b4436d8b2d62d0d5fba7.tar.gz gdb-7ca2d3a37165b1847d70b4436d8b2d62d0d5fba7.tar.bz2 |
2004-08-29 David Lecomber <david@streamline-computing.com>
Fix PR gdb/648
* language.h (enum array_ordering): New enum.
* language.h (struct language_defn): New la_array_ordering
attribute.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Ditto.
* ada-lang.c (ada_language_defn): Ditto.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Ditto.
* f-lang.c (f_language_defn): Ditto.
* jv-lang.c (java_language_defn): Ditto.
* m2-lang.c (f_language_defn): Ditto.
* objc-lang.c (objc_language_defn): Ditto.
* p-lang.c (pascal_language_defn): Ditto.
* scm-lang.c (scm_language_defn): Ditto.
* eval.c (evaluate_subexp_standard): Assume Fortran arrays are
oriented large to small in type structure.
* dwarf2read.c (read_array_order): New function.
(read_array_type): Use read_array_order to check row/column
major ordering.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r-- | gdb/eval.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -1610,9 +1610,8 @@ evaluate_subexp_standard (struct type *expect_type, 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 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 */ @@ -1630,7 +1629,8 @@ evaluate_subexp_standard (struct type *expect_type, let us actually find out where this element exists in the array. */ offset_item = 0; - for (i = 1; i <= nargs; i++) + /* 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); @@ -1638,7 +1638,11 @@ evaluate_subexp_standard (struct type *expect_type, /* 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"); @@ -1647,11 +1651,11 @@ evaluate_subexp_standard (struct type *expect_type, if (retcode == BOUND_FETCH_ERROR) error ("Cannot obtain dynamic lower bound"); - array_size_array[i] = upper - lower + 1; + array_size_array[nargs - i - 1] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ - subscript_array[i] -= lower; + 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 @@ -1661,17 +1665,17 @@ evaluate_subexp_standard (struct type *expect_type, of base element type that we apply a simple offset to. */ - if (i < nargs) + 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]; + offset_item = subscript_array[ndimensions - 1]; - for (i = ndimensions - 1; i >= 1; i--) + for (i = ndimensions - 1; i > 0; --i) offset_item = - array_size_array[i] * offset_item + subscript_array[i]; + array_size_array[i - 1] * offset_item + subscript_array[i - 1]; /* Construct a value node with the value of the offset */ |