typedef struct subscript_range
{
enum range_type f90_range_type;
- LONGEST low, high;
+ LONGEST low, high, stride;
} subscript_range;
typedef enum subscript_kind
== SUBARRAY_HIGH_BOUND)
range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
pos, noside));
+
+ /* Assign the user's stride value if provided. */
+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
+ pos, noside));
+
+ /* Assign the default stride value '1'. */
+ else
+ range->stride = 1;
}
/* User input is an index. E.g.: "p arry(5)". */
else
extern void dump_prefix_expression (struct expression *, struct ui_file *);
/* In an OP_RANGE expression, either bound can be provided by the user, or not.
- This enumeration type is to identify this. */
+ In addition to this, the user can also specify a stride value to indicated
+ only certain elements of the array. This enumeration type is to identify
+ this. */
enum range_type
{
SUBARRAY_NONE_BOUND = 0x0, /* "( : )" */
SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */
- SUBARRAY_HIGH_BOUND = 0x2 /* "(:high)" */
+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" */
+ SUBARRAY_STRIDE = 0x4 /* "(::stride)" */
};
#endif /* !defined (EXPRESSION_H) */
subrange: ':' %prec ABOVE_COMMA
{ write_exp_elt_opcode (pstate, OP_RANGE);
- write_exp_elt_longcst (pstate, 0);
+ write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND);
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+/* Each subrange type can have a stride argument. */
+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
+ | SUBARRAY_HIGH_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: exp ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_RANGE); }
+ ;
+
+subrange: ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
write_exp_elt_opcode (pstate, OP_RANGE); }
;
if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
args++;
+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
+ args++;
+
break;
default:
if (call_count == 1)
{
range_type = TYPE_INDEX_TYPE (array_type);
- slice_range_size = elem_count;
+ slice_range_size = ary_low_bound + elem_count - 1;
/* Check if the array bounds are valid. */
if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0)
else
{
range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type));
- slice_range_size = (ary_low_bound + row_count - 1) * (elem_count);
+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1;
ary_low_bound = TYPE_LOW_BOUND (range_type);
}