2017-09-11 Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog:
* eval.c (Evaluate_subexp_standard): Use new function name.
(value_f90_subarray): Move ...
* f-lang.c (f90_value_subarray): ... here.
* f-lang.h (f90_value_subarray): New declaration.
---
gdb/eval.c | 30 ++----------------------------
gdb/f-lang.c | 27 +++++++++++++++++++++++++++
gdb/f-lang.h | 5 +++++
3 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 7a808a0..557ac02 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -384,32 +384,6 @@ init_array_element (struct value *array, struct
value *element,
return index;
}
-static struct value *
-value_f90_subarray (struct value *array,
- struct expression *exp, int *pos, enum noside noside)
-{
- int pc = (*pos) + 1;
- LONGEST low_bound, high_bound;
- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type
(array)));
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
-
- *pos += 3;
-
- if (range_type == LOW_BOUND_DEFAULT || range_type ==
BOTH_BOUND_DEFAULT)
- low_bound = TYPE_LOW_BOUND (range);
- else
- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos,
noside));
-
- if (range_type == HIGH_BOUND_DEFAULT || range_type ==
BOTH_BOUND_DEFAULT)
- high_bound = TYPE_HIGH_BOUND (range);
- else
- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos,
noside));
-
- return value_slice (array, low_bound, high_bound - low_bound + 1);
-}
-
-
/* Promote value ARG1 as appropriate before performing a unary
operation
on this argument.
If the result is not appropriate for any particular language then
it
@@ -1916,13 +1890,13 @@ evaluate_subexp_standard (struct type
*expect_type,
{
case TYPE_CODE_ARRAY:
if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
+ return f90_value_subarray (arg1, exp, pos, noside);
else
goto multi_f77_subscript;
case TYPE_CODE_STRING:
if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
+ return f90_value_subarray (arg1, exp, pos, noside);
else
{
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 77b759b..63caf65 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -386,3 +386,30 @@ f77_get_array_dims (const struct type *array_type)
return ndimen;
}
+
+/* See f-lang.h. */
+
+struct value *
+f90_value_subarray (struct value *array, struct expression *exp, int
*pos,
+ enum noside noside)
+{
+ int pc = (*pos) + 1;
+ LONGEST low_bound, high_bound;
+ struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type
(array)));
+ enum range_type range_type
+ = (enum range_type) longest_to_int (exp->elts[pc].longconst);
+
+ *pos += 3;
+
+ if (range_type == LOW_BOUND_DEFAULT || range_type ==
BOTH_BOUND_DEFAULT)
+ low_bound = TYPE_LOW_BOUND (range);
+ else
+ low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos,
noside));
+
+ if (range_type == HIGH_BOUND_DEFAULT || range_type ==
BOTH_BOUND_DEFAULT)
+ high_bound = TYPE_HIGH_BOUND (range);
+ else
+ high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos,
noside));
+
+ return value_slice (array, low_bound, high_bound - low_bound + 1);
+}
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index cfe667b..013ea5e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -59,6 +59,11 @@ extern void f77_get_dynamic_array_length (struct
type *);
* the type of an array. */
extern int f77_get_array_dims (const struct type *array_type);
+/* Evaluates any subarray operation on Fortran arrays with at least
one user
+ provided parameter. Expects the input ARRAY to be an array. */
+extern struct value *f90_value_subarray (struct value *array,
+ struct expression *exp,
+ int *pos, enum noside noside);
/* Fortran (F77) types */