@@ -1889,19 +1889,8 @@ evaluate_subexp_standard (struct type *expect_type,
switch (code)
{
case TYPE_CODE_ARRAY:
- if (exp->elts[*pos].opcode == OP_RANGE)
- 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 f90_value_subarray (arg1, exp, pos, noside);
- else
- {
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- return value_subscript (arg1, value_as_long (arg2));
- }
+ return f90_value_subarray (arg1, exp, pos, nargs, noside);
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
@@ -2301,49 +2290,6 @@ evaluate_subexp_standard (struct type *expect_type,
}
return (arg1);
- multi_f77_subscript:
- {
- LONGEST subscript_array[MAX_FORTRAN_DIMS];
- int ndimensions = 1, i;
- struct value *array = arg1;
-
- if (nargs > MAX_FORTRAN_DIMS)
- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
-
- ndimensions = f77_get_array_dims (type);
-
- if (nargs != ndimensions)
- error (_("Wrong number of subscripts"));
-
- gdb_assert (nargs > 0);
-
- /* Now that we know we have a legal array subscript expression
- let us actually find out where this element exists in the array. */
-
- /* 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);
-
- /* Fill in the subscript array. */
-
- subscript_array[i] = value_as_long (arg2);
- }
-
- /* Internal type of array is arranged right to left. */
- for (i = nargs; i > 0; i--)
- {
- struct type *array_type = check_typedef (value_type (array));
- LONGEST index = subscript_array[i - 1];
-
- array = value_subscripted_rvalue (array, index,
- f77_get_lowerbound (array_type));
- }
-
- return array;
- }
-
case BINOP_LOGICAL_AND:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
@@ -254,6 +254,8 @@ arglist : subrange
arglist : arglist ',' exp %prec ABOVE_COMMA
{ arglist_len++; }
+ | arglist ',' subrange %prec ABOVE_COMMA
+ { arglist_len++; }
;
/* There are four sorts of subrange types in F90. */
@@ -376,6 +376,9 @@ _initialize_f_language (void)
int
f77_get_array_dims (const struct type *array_type)
{
+ if (TYPE_CODE (array_type) == TYPE_CODE_STRING)
+ return 1;
+
if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
error (_("Can't get dimensions for a non-array type"));
@@ -387,29 +390,209 @@ f77_get_array_dims (const struct type *array_type)
return ndimen;
}
+/* F90_VALUE_SLICE is called for each array dimension to calculate the number
+ of elements as defined by the subscript expression
+ array(SLICE_LOW : SLICE_LOW + SLICE_LEN).
+ MULTI_DIM is used to determine if we are working on a one-dimensional or
+ multi-dimensional array. The latter case happens in all slicing operations
+ following the first subscript that is a range, as a range subscript does not
+ decrease the number of dimensions of an array. */
+
+static struct value *
+f90_value_slice (struct value *src_array, LONGEST slice_low, LONGEST slice_len,
+ bool multi_dim)
+{
+ /* If the array is not multidimensional, we use the generic code path to
+ generate the slice. */
+ if (!multi_dim)
+ return value_slice (src_array, slice_low, slice_len);
+
+ type *const src_ary_type = check_typedef (value_type (src_array));
+ type *const src_row_type = check_typedef (TYPE_TARGET_TYPE (src_ary_type));
+ type *const src_elm_type = check_typedef (TYPE_TARGET_TYPE (src_row_type));
+ type *const src_idx_type = check_typedef (TYPE_INDEX_TYPE (src_row_type));
+ const LONGEST slice_offset = slice_low - TYPE_LOW_BOUND (src_idx_type);
+ const LONGEST row_count
+ = TYPE_LENGTH (src_ary_type) / TYPE_LENGTH (src_row_type);
+
+ /* FIXME-type-allocation: need a way to free this type when we are
+ done with it. */
+ type *const dst_rng_type
+ = create_static_range_type (NULL, TYPE_TARGET_TYPE (src_idx_type),
+ TYPE_LOW_BOUND (src_idx_type),
+ TYPE_LOW_BOUND (src_idx_type)
+ + slice_len * row_count - 1);
+
+ type *const dst_ary_type
+ = create_array_type (NULL, TYPE_TARGET_TYPE (src_row_type), dst_rng_type);
+
+ TYPE_CODE (dst_ary_type) = TYPE_CODE (src_row_type);
+ value *const dst_array = allocate_value (dst_ary_type);
+
+ for (LONGEST i = 0; i < row_count; ++i)
+ {
+ const LONGEST dst_offset = TYPE_LENGTH (src_elm_type) * i * slice_len;
+
+ const LONGEST src_offset
+ = TYPE_LENGTH (src_row_type) * i
+ + TYPE_LENGTH (src_elm_type) * slice_offset;
+
+ value_contents_copy (dst_array, dst_offset, src_array, src_offset,
+ TYPE_LENGTH (src_elm_type) * slice_len);
+ }
+
+ const LONGEST offset
+ = TYPE_LENGTH (src_row_type) * row_count
+ + TYPE_LENGTH (src_elm_type) * slice_offset;
+
+ set_value_component_location (dst_array, src_array);
+ set_value_offset (dst_array, value_offset (src_array) + offset);
+
+ return dst_array;
+}
+
/* See f-lang.h. */
struct value *
f90_value_subarray (struct value *array, struct expression *exp, int *pos,
- enum noside noside)
+ int nargs, 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);
+ /* Local struct to hold user data for Fortran subarray dimensions. */
+ struct subscript
+ {
+ enum
+ {
+ SUBSCRIPT_INDEX, /* e.g. "(literal)" */
+ SUBSCRIPT_RANGE /* e.g. "(lowbound:highbound)" */
+ } kind;
+
+ union
+ {
+ /* If KIND == SUBSCRIPT_INDEX. */
+ LONGEST index;
+
+ /* If KIND == SUBSCRIPT_RANGE. */
+ struct {
+ int type;
+ LONGEST low;
+ LONGEST high;
+ };
+ };
+
+ subscript (LONGEST index_) : kind (SUBSCRIPT_INDEX), index (index_) {}
+
+ subscript (int type_, LONGEST low_, LONGEST high_) :
+ kind (SUBSCRIPT_RANGE), type (type_), low (low_), high (high_) {}
+ };
+
+ if (nargs != f77_get_array_dims (value_type (array)))
+ error (_("Wrong number of subscripts"));
+
+ /* Parse the user input into SUBSCRIPT_ARRAY for later use. We need to parse
+ it fully first, as evaluation is performed right-to-left. */
+ std::vector<subscript> subscript_array;
+ for (int i = 0; i < nargs; i++)
+ {
+ if (exp->elts[*pos].opcode == OP_RANGE)
+ {
+ /* User input is a range, with or without lower and upper bound,
+ e.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */
+ const int type = longest_to_int (exp->elts[*pos + 1].longconst);
+ LONGEST lo = 0;
+ LONGEST hi = 0;
+
+ *pos += 3;
+
+ if (type == HIGH_BOUND_DEFAULT || type == NONE_BOUND_DEFAULT)
+ lo = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ if (type == LOW_BOUND_DEFAULT || type == NONE_BOUND_DEFAULT)
+ hi = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+
+ subscript_array.emplace_back (type, lo, hi);
+ }
+ else
+ {
+ /* User input is an index, e.g.: "p arry(5)". The subscript must be
+ a legal integer in F77. */
+ value *const val = evaluate_subexp_with_coercion (exp, pos, noside);
+ subscript_array.emplace_back (value_as_long (val));
+ }
+ }
- *pos += 3;
+ /* Traverse the array from right to left and evaluate each corresponding
+ user input. */
+ bool multi_dim = false;
+ const type *array_type = check_typedef (value_type (array));
+ value *new_array = array;
+ for (auto it = subscript_array.rbegin (); it != subscript_array.rend ();
+ array_type = TYPE_TARGET_TYPE (array_type), ++it)
+ {
+ const type *const index_type = TYPE_INDEX_TYPE (array_type);
+ const LONGEST lo = TYPE_LOW_BOUND (index_type);
+ const LONGEST hi = TYPE_HIGH_BOUND (index_type);
- 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 (it->kind == subscript::SUBSCRIPT_RANGE)
+ {
+ if (it->type == LOW_BOUND_DEFAULT || it->type == BOTH_BOUND_DEFAULT)
+ it->low = lo;
+ if (it->type == HIGH_BOUND_DEFAULT || it->type == BOTH_BOUND_DEFAULT)
+ it->high = hi;
+
+ if (it->low < lo || it->low > hi || it->high < lo || it->high > hi)
+ error (_("slice out of range"));
+
+ if (it->high - it->low + 1 < 0)
+ error (_("slice out of range"));
+
+ new_array = f90_value_slice (new_array, it->low,
+ it->high - it->low + 1,
+ multi_dim);
+
+ /* A range subscript does not decrease the number of dimensions in
+ array. Therefore we cannot use VALUE_SUBSCRIPTED_RVALUE anymore
+ after we encountered the first range, as we now operate on an
+ array of arrays. */
+ multi_dim = true;
+ }
+ else
+ {
+ if (!multi_dim)
+ {
+ const int lo = f77_get_lowerbound (value_type (new_array));
+ new_array = value_subscripted_rvalue (new_array, it->index, lo);
+ continue;
+ }
- 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));
+ if (it->index < lo || it->index > hi)
+ error (_("no such vector element"));
+
+ new_array = f90_value_slice (new_array, it->index, 1, multi_dim);
+ }
+ }
+
+ /* If we did not encounter any range subscript, the result is ready to go. */
+ if (!multi_dim)
+ return new_array;
+
+ /* After slicing, NEW_ARRAY is a flat, one-dimensional array. If we had any
+ range subscripts, we have to rebuild the dimensions with respect to the
+ stride size. */
+ type *elt_type = TYPE_TARGET_TYPE (value_type (new_array));
+ for (const subscript& s : subscript_array)
+ {
+ if (s.kind == subscript::SUBSCRIPT_INDEX)
+ continue;
+
+ type *const range_type =
+ create_static_range_type (NULL, elt_type, s.low, s.high);
+ type *const interim_array_type =
+ create_array_type (NULL, elt_type, range_type);
+
+ TYPE_CODE (interim_array_type) = TYPE_CODE (value_type (new_array));
+ array = allocate_value (interim_array_type);
+ elt_type = value_type (array);
+ }
- return value_slice (array, low_bound, high_bound - low_bound + 1);
+ value_contents_copy (array, 0, new_array, 0, TYPE_LENGTH (elt_type));
+ return array;
}
@@ -59,11 +59,15 @@ 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. */
+/* Evaluates any subarray operation on Fortran arrays or strings with at least
+ one user provided parameter. Expects the input ARRAY to be either an array
+ or a string. Evaluates EXP by incrementing *POS. NARGS specifies number of
+ arguments the user provided and must be the same number as ARRAY has
+ dimensions. */
extern struct value *f90_value_subarray (struct value *array,
struct expression *exp,
- int *pos, enum noside noside);
+ int *pos, int nargs,
+ enum noside noside);
/* Fortran (F77) types */
new file mode 100644
@@ -0,0 +1,275 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if { [skip_fortran_tests] } {
+ return -1
+}
+
+standard_testfile static-arrays.f90
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ untested "could not run to main"
+ return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "BP1"]
+gdb_continue_to_breakpoint "BP1" ".*BP1.*"
+
+
+# Test subranges of one-dimensional arrays
+gdb_test "p ar1" " = \\(1, 2, 3, 4\\)"
+gdb_test "p ar1\(2:3\)" " = \\(2, 3\\)"
+gdb_test "p ar1\(2: \)" " = \\(2, 3, 4\\)"
+gdb_test "p ar1\( :3\)" " = \\(1, 2, 3\\)"
+gdb_test "p ar1\( : \)" " = \\(1, 2, 3, 4\\)"
+gdb_test "p ar1\( 3 \)" " = 3"
+
+
+# Test subranges of two-dimensional arrays
+gdb_test "p ar2\(2:3,3:4\)" " = \\(\\( 23, 33\\) \\( 24, 34\\) \\)"
+gdb_test "p ar2\(2:3,3: \)" " = \\(\\( 23, 33\\) \\( 24, 34\\) \\)"
+gdb_test "p ar2\(2:3, :2\)" " = \\(\\( 21, 31\\) \\( 22, 32\\) \\)"
+gdb_test "p ar2\(2:3, : \)" " = \\(\\( 21, 31\\) \\( 22, 32\\) \\( 23, 33\\) \\( 24, 34\\) \\)"
+gdb_test "p ar2\(2:3, 4 \)" " = \\(24, 34\\)"
+
+gdb_test "p ar2\(3: ,3:4\)" " = \\(\\( 33, 43\\) \\( 34, 44\\) \\)"
+gdb_test "p ar2\(3: ,3: \)" " = \\(\\( 33, 43\\) \\( 34, 44\\) \\)"
+gdb_test "p ar2\(3: , :2\)" " = \\(\\( 31, 41\\) \\( 32, 42\\) \\)"
+gdb_test "p ar2\(3: , : \)" " = \\(\\( 31, 41\\) \\( 32, 42\\) \\( 33, 43\\) \\( 34, 44\\) \\)"
+gdb_test "p ar2\(3: , 4 \)" " = \\(34, 44\\)"
+
+gdb_test "p ar2\( :2,2:3\)" " = \\(\\( 12, 22\\) \\( 13, 23\\) \\)"
+gdb_test "p ar2\( :2,3: \)" " = \\(\\( 13, 23\\) \\( 14, 24\\) \\)"
+gdb_test "p ar2\( :2, :2\)" " = \\(\\( 11, 21\\) \\( 12, 22\\) \\)"
+gdb_test "p ar2\( :2, : \)" " = \\(\\( 11, 21\\) \\( 12, 22\\) \\( 13, 23\\) \\( 14, 24\\) \\)"
+gdb_test "p ar2\( :2, 4 \)" " = \\(14, 24\\)"
+
+gdb_test "p ar2\( 1 ,1:2\)" " = \\(11, 12\\)"
+gdb_test "p ar2\( 1 ,2: \)" " = \\(12, 13, 14\\)"
+gdb_test "p ar2\( 1 , :2\)" " = \\(11, 12\\)"
+gdb_test "p ar2\( 1 , : \)" " = \\(11, 12, 13, 14\\)"
+gdb_test "p ar2\( 1 , 4 \)" " = 14"
+
+gdb_test "p ar2\( : ,3:4\)" " = \\(\\( 13, 23, 33, 43\\) \\( 14, 24, 34, 44\\) \\)"
+gdb_test "p ar2\( : ,3: \)" " = \\(\\( 13, 23, 33, 43\\) \\( 14, 24, 34, 44\\) \\)"
+gdb_test "p ar2\( : , :4\)" " = \\(\\( 11, 21, 31, 41\\) \\( 12, 22, 32, 42\\) \\( 13, 23, 33, 43\\) \\( 14, 24, 34, 44\\) \\)"
+gdb_test "p ar2\( : , : \)" " = \\(\\( 11, 21, 31, 41\\) \\( 12, 22, 32, 42\\) \\( 13, 23, 33, 43\\) \\( 14, 24, 34, 44\\) \\)"
+gdb_test "p ar2\( : , 2 \)" " = \\(12, 22, 32, 42\\)"
+
+
+# Test subarrays of 3 dimensional arrays
+gdb_test "p ar3\(1:2,2:3,3:4\)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2,2:3,3: \)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2,2:3, :4\)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2,2:3, : \)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2,2:3, 1 \)" " = \\(\\( 121, 221\\) \\( 131, 231\\) \\)"
+
+gdb_test "p ar3\(1:2,2: ,3:4\)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2,2: ,3: \)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2,2: , :4\)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2,2: , : \)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2,2: , 1 \)" " = \\(\\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\)"
+
+gdb_test "p ar3\(1:2, :3,3:4\)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2, :3,3: \)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2, :3, :4\)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2, :3, : \)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\(1:2, :3, 1 \)" " = \\(\\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\)"
+
+gdb_test "p ar3\(1:2, : ,3:4\)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2, : ,3: \)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2, : , :4\)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2, : , : \)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\(1:2, : , 1 \)" " = \\(\\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\)"
+
+gdb_test "p ar3\(1:2, 2 ,3:4\)" " = \\(\\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\(1:2, 2 ,3: \)" " = \\(\\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\(1:2, 2 , :4\)" " = \\(\\( 121, 221\\) \\( 122, 222\\) \\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\(1:2, 2 , : \)" " = \\(\\( 121, 221\\) \\( 122, 222\\) \\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\(1:2, 2 , 1 \)" " = \\(121, 221\\)"
+
+
+gdb_test "p ar3\(1: ,2:3,3:4\)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: ,2:3,3: \)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: ,2:3, :4\)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: ,2:3, : \)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: ,2:3, 1 \)" " = \\(\\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\)"
+
+gdb_test "p ar3\(1: ,2: ,3:4\)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: ,2: ,3: \)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: ,2: , :4\)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: ,2: , : \)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: ,2: , 1 \)" " = \\(\\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\)"
+
+gdb_test "p ar3\(1: , :3,3:4\)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: , :3,3: \)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: , :3, :4\)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: , :3, : \)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\(1: , :3, 1 \)" " = \\(\\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\)"
+
+gdb_test "p ar3\(1: , : ,3:4\)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: , : ,3: \)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: , : , :4\)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: , : , : \)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\(1: , : , 1 \)" " = \\(\\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\)"
+
+gdb_test "p ar3\(1: , 2 ,3:4\)" " = \\(\\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\(1: , 2 ,3: \)" " = \\(\\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\(1: , 2 , :4\)" " = \\(\\( 121, 221, 321, 421\\) \\( 122, 222, 322, 422\\) \\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\(1: , 2 , : \)" " = \\(\\( 121, 221, 321, 421\\) \\( 122, 222, 322, 422\\) \\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\(1: , 2 , 1 \)" " = \\(121, 221, 321, 421\\)"
+
+
+gdb_test "p ar3\( :2,2:3,3:4\)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2,2:3,3: \)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2,2:3, :4\)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2,2:3, : \)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2,2:3, 1 \)" " = \\(\\( 121, 221\\) \\( 131, 231\\) \\)"
+
+gdb_test "p ar3\( :2,2: ,3:4\)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2,2: ,3: \)" " = \\(\\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2,2: , :4\)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2,2: , : \)" " = \\(\\( \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2,2: , 1 \)" " = \\(\\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\)"
+
+gdb_test "p ar3\( :2, :3,3:4\)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2, :3,3: \)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2, :3, :4\)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2, :3, : \)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\) \\)"
+gdb_test "p ar3\( :2, :3, 1 \)" " = \\(\\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\)"
+
+gdb_test "p ar3\( :2, : ,3:4\)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2, : ,3: \)" " = \\(\\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2, : , :4\)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2, : , : \)" " = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\) \\( \\( 112, 212\\) \\( 122, 222\\) \\( 132, 232\\) \\( 142, 242\\) \\) \\( \\( 113, 213\\) \\( 123, 223\\) \\( 133, 233\\) \\( 143, 243\\) \\) \\( \\( 114, 214\\) \\( 124, 224\\) \\( 134, 234\\) \\( 144, 244\\) \\) \\)"
+gdb_test "p ar3\( :2, : , 1 \)" " = \\(\\( 111, 211\\) \\( 121, 221\\) \\( 131, 231\\) \\( 141, 241\\) \\)"
+
+gdb_test "p ar3\( :2, 2 ,3:4\)" " = \\(\\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\( :2, 2 ,3: \)" " = \\(\\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\( :2, 2 , :4\)" " = \\(\\( 121, 221\\) \\( 122, 222\\) \\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\( :2, 2 , : \)" " = \\(\\( 121, 221\\) \\( 122, 222\\) \\( 123, 223\\) \\( 124, 224\\) \\)"
+gdb_test "p ar3\( :2, 2 , 1 \)" " = \\(121, 221\\)"
+
+
+gdb_test "p ar3\( : ,2:3,3:4\)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : ,2:3,3: \)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : ,2:3, :4\)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : ,2:3, : \)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : ,2:3, 1 \)" " = \\(\\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\)"
+
+gdb_test "p ar3\( : ,2: ,3:4\)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : ,2: ,3: \)" " = \\(\\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : ,2: , :4\)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : ,2: , : \)" " = \\(\\( \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : ,2: , 1 \)" " = \\(\\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\)"
+
+gdb_test "p ar3\( : , :3,3:4\)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : , :3,3: \)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : , :3, :4\)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : , :3, : \)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\) \\)"
+gdb_test "p ar3\( : , :3, 1 \)" " = \\(\\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\)"
+
+gdb_test "p ar3\( : , : ,3:4\)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : , : ,3: \)" " = \\(\\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : , : , :4\)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : , : , : \)" " = \\(\\( \\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\) \\( \\( 112, 212, 312, 412\\) \\( 122, 222, 322, 422\\) \\( 132, 232, 332, 432\\) \\( 142, 242, 342, 442\\) \\) \\( \\( 113, 213, 313, 413\\) \\( 123, 223, 323, 423\\) \\( 133, 233, 333, 433\\) \\( 143, 243, 343, 443\\) \\) \\( \\( 114, 214, 314, 414\\) \\( 124, 224, 324, 424\\) \\( 134, 234, 334, 434\\) \\( 144, 244, 344, 444\\) \\) \\)"
+gdb_test "p ar3\( : , : , 1 \)" " = \\(\\( 111, 211, 311, 411\\) \\( 121, 221, 321, 421\\) \\( 131, 231, 331, 431\\) \\( 141, 241, 341, 441\\) \\)"
+
+gdb_test "p ar3\( : , 2 ,3:4\)" " = \\(\\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\( : , 2 ,3: \)" " = \\(\\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\( : , 2 , :4\)" " = \\(\\( 121, 221, 321, 421\\) \\( 122, 222, 322, 422\\) \\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\( : , 2 , : \)" " = \\(\\( 121, 221, 321, 421\\) \\( 122, 222, 322, 422\\) \\( 123, 223, 323, 423\\) \\( 124, 224, 324, 424\\) \\)"
+gdb_test "p ar3\( : , 2 , 1 \)" " = \\(121, 221, 321, 421\\)"
+
+
+gdb_test "p ar3\( 1 ,2:3,3:4\)" " = \\(\\( 123, 133\\) \\( 124, 134\\) \\)"
+gdb_test "p ar3\( 1 ,2:3,3: \)" " = \\(\\( 123, 133\\) \\( 124, 134\\) \\)"
+gdb_test "p ar3\( 1 ,2:3, :4\)" " = \\(\\( 121, 131\\) \\( 122, 132\\) \\( 123, 133\\) \\( 124, 134\\) \\)"
+gdb_test "p ar3\( 1 ,2:3, : \)" " = \\(\\( 121, 131\\) \\( 122, 132\\) \\( 123, 133\\) \\( 124, 134\\) \\)"
+gdb_test "p ar3\( 1 ,2:3, 1 \)" " = \\(121, 131\\)"
+
+gdb_test "p ar3\( 1 ,2: ,3:4\)" " = \\(\\( 123, 133, 143\\) \\( 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 ,2: ,3: \)" " = \\(\\( 123, 133, 143\\) \\( 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 ,2: , :4\)" " = \\(\\( 121, 131, 141\\) \\( 122, 132, 142\\) \\( 123, 133, 143\\) \\( 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 ,2: , : \)" " = \\(\\( 121, 131, 141\\) \\( 122, 132, 142\\) \\( 123, 133, 143\\) \\( 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 ,2: , 1 \)" " = \\(121, 131, 141\\)"
+
+gdb_test "p ar3\( 1 , :3,3:4\)" " = \\(\\( 113, 123, 133\\) \\( 114, 124, 134\\) \\)"
+gdb_test "p ar3\( 1 , :3,3: \)" " = \\(\\( 113, 123, 133\\) \\( 114, 124, 134\\) \\)"
+gdb_test "p ar3\( 1 , :3, :4\)" " = \\(\\( 111, 121, 131\\) \\( 112, 122, 132\\) \\( 113, 123, 133\\) \\( 114, 124, 134\\) \\)"
+gdb_test "p ar3\( 1 , :3, : \)" " = \\(\\( 111, 121, 131\\) \\( 112, 122, 132\\) \\( 113, 123, 133\\) \\( 114, 124, 134\\) \\)"
+gdb_test "p ar3\( 1 , :3, 1 \)" " = \\(111, 121, 131\\)"
+
+gdb_test "p ar3\( 1 , : ,3:4\)" " = \\(\\( 113, 123, 133, 143\\) \\( 114, 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 , : ,3: \)" " = \\(\\( 113, 123, 133, 143\\) \\( 114, 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 , : , :4\)" " = \\(\\( 111, 121, 131, 141\\) \\( 112, 122, 132, 142\\) \\( 113, 123, 133, 143\\) \\( 114, 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 , : , : \)" " = \\(\\( 111, 121, 131, 141\\) \\( 112, 122, 132, 142\\) \\( 113, 123, 133, 143\\) \\( 114, 124, 134, 144\\) \\)"
+gdb_test "p ar3\( 1 , : , 1 \)" " = \\(111, 121, 131, 141\\)"
+
+gdb_test "p ar3\( 1 , 2 ,3:4\)" " = \\(123, 124\\)"
+gdb_test "p ar3\( 1 , 2 ,3: \)" " = \\(123, 124\\)"
+gdb_test "p ar3\( 1 , 2 , :4\)" " = \\(121, 122, 123, 124\\)"
+gdb_test "p ar3\( 1 , 2 , : \)" " = \\(121, 122, 123, 124\\)"
+gdb_test "p ar3\( 1 , 2 , 1 \)" " = 121"
+
+
+# Check negative indices and slices
+gdb_test "p ar4" " = \\(-4, -3, -2, -1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\(-3:-1\)" " = \\(-3, -2, -1\\)"
+gdb_test "p ar4\(-3: 1\)" " = \\(-3, -2, -1, 0, 1\\)"
+gdb_test "p ar4\(-1: 3\)" " = \\(-1, 0, 1, 2, 3\\)"
+gdb_test "p ar4\(-1: 4\)" " = \\(-1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\(-4: \)" " = \\(-4, -3, -2, -1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\(-3: \)" " = \\(-3, -2, -1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\( 1: \)" " = \\(1, 2, 3, 4\\)"
+gdb_test "p ar4\( 4: \)" " = \\(4\\)"
+gdb_test "p ar4\( :-4\)" " = \\(-4\\)"
+gdb_test "p ar4\( :-3\)" " = \\(-4, -3\\)"
+gdb_test "p ar4\( : 1\)" " = \\(-4, -3, -2, -1, 0, 1\\)"
+gdb_test "p ar4\( : 4\)" " = \\(-4, -3, -2, -1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\( : \)" " = \\(-4, -3, -2, -1, 0, 1, 2, 3, 4\\)"
+gdb_test "p ar4\( -4 \)" " = -4"
+gdb_test "p ar4\( -3 \)" " = -3"
+gdb_test "p ar4\( 1 \)" " = 1"
+gdb_test "p ar4\( 4 \)" " = 4"
+
+
+# Check assignment
+gdb_test_no_output "set \$my_ary = ar1\(2:4\)"
+gdb_test "p \$my_ary" " = \\(2, 3, 4\\)" "p my_ary one"
+gdb_test_no_output "set ar1\(2\) = 1"
+gdb_test "p ar1\(2:4\)" " = \\(1, 3, 4\\)"
+gdb_test "p \$my_ary" " = \\(2, 3, 4\\)" "p my_ary two"
+
+
+# Corner cases and error messages
+gdb_test "p ar1\(\)" "Wrong number of subscripts"
+gdb_test "p ar1\(9\)" "no such vector element"
+gdb_test "p ar1\(0:4\)" "slice out of range"
+gdb_test "p ar1\(2:7\)" "slice out of range"
+gdb_test "p ar1\(3:4\) = 42" "Invalid cast."
+gdb_test "p ar1\(3:3\)" " = \\(3\\)"
+gdb_test "p ar1\(3:2\)" " = \\(\\)"
+gdb_test "p ar1\(3:1\)" "slice out of range"
+gdb_test "p ar2\(3:3, :\)" "\\(\\( 31\\) \\( 32\\) \\( 33\\) \\( 34\\) \\)"
+gdb_test "p ar2\(3:2, :\)" "\\(\\( \\) \\( \\) \\( \\) \\( \\) \\)"
+gdb_test "p ar2\(3:1, :\)" "slice out of range"
+gdb_test "p ar4\(-3:-3\)" " = \\(-3\\)"
+gdb_test "p ar4\(-2:-3\)" " = \\(\\)"
+gdb_test "p ar4\( 1:-1\)" "slice out of range"
new file mode 100644
@@ -0,0 +1,44 @@
+! Copyright 2017 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+subroutine sub
+ integer, dimension(4) :: ar1
+ integer, dimension(4,4) :: ar2
+ integer, dimension(4,4,4) :: ar3
+ integer, dimension(-4:4) :: ar4
+ integer :: i,j,k
+
+ ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...)))
+ do i = 1, 4, 1
+ ar1(i) = i
+ do j = 1, 4, 1
+ ar2(i,j) = i*10 + j
+ do k = 1, 4, 1
+ ar3(i,j,k) = i*100 + j*10 + k
+ end do
+ end do
+ end do
+
+ do i = -4, 4, 1
+ ar4(i) = i
+ end do
+
+ ar1(1) = 11 !BP1
+ return
+end
+
+program testprog
+ call sub
+end