a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-vla-intel-fortran-strides.patch
f524ac5
f637971
;; VLA (Fortran dynamic arrays) from Intel + archer-jankratochvil-vla tests.
f637971
;;=push
f637971
Jan Kratochvil 72aed9d
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-strides
Jan Kratochvil d258670
dbfd7140bf4c0500d1f5d192be781f83f78f7922
Jan Kratochvil 72aed9d
Jan Kratochvil d258670
 gdb/dwarf2loc.c                             |  46 ++-
Jan Kratochvil d258670
 gdb/dwarf2loc.h                             |   6 +
Jan Kratochvil 72aed9d
 gdb/dwarf2read.c                            |  13 +-
Jan Kratochvil 72aed9d
 gdb/eval.c                                  | 391 +++++++++++++++++++++-----
Jan Kratochvil 72aed9d
 gdb/expprint.c                              |  20 +-
Jan Kratochvil 72aed9d
 gdb/expression.h                            |  18 +-
Jan Kratochvil 72aed9d
 gdb/f-exp.y                                 |  42 ++-
Jan Kratochvil 72aed9d
 gdb/f-valprint.c                            |   8 +-
Jan Kratochvil d258670
 gdb/gdbtypes.c                              |  34 ++-
Jan Kratochvil d258670
 gdb/gdbtypes.h                              |  18 +-
Jan Kratochvil 72aed9d
 gdb/parse.c                                 |  24 +-
Jan Kratochvil 72aed9d
 gdb/rust-exp.y                              |  12 +-
Jan Kratochvil 72aed9d
 gdb/rust-lang.c                             |  17 +-
Jan Kratochvil 72aed9d
 gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++
Jan Kratochvil 72aed9d
 gdb/testsuite/gdb.fortran/static-arrays.f90 |  55 ++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-ptype.exp     |   4 +
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-sizeof.exp    |   4 +
Jan Kratochvil 72aed9d
 gdb/testsuite/gdb.fortran/vla-stride.exp    |  44 +++
Jan Kratochvil 72aed9d
 gdb/testsuite/gdb.fortran/vla-stride.f90    |  29 ++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla.f90           |  10 +
Jan Kratochvil d258670
 gdb/valarith.c                              |  10 +-
Jan Kratochvil 72aed9d
 gdb/valops.c                                | 197 +++++++++++--
Jan Kratochvil 72aed9d
 gdb/value.h                                 |   2 +
Jan Kratochvil d258670
 23 files changed, 1242 insertions(+), 183 deletions(-)
Jan Kratochvil 72aed9d
f637971
diff --git a/gdb/eval.c b/gdb/eval.c
f637971
--- a/gdb/eval.c
f637971
+++ b/gdb/eval.c
0a2f2a5
@@ -372,29 +372,324 @@ init_array_element (struct value *array, struct value *element,
Jan Kratochvil 72aed9d
   return index;
Jan Kratochvil 72aed9d
 }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
+/* Evaluates any operation on Fortran arrays or strings with at least
Jan Kratochvil 72aed9d
+   one user provided parameter.  Expects the input ARRAY to be either
Jan Kratochvil 72aed9d
+   an array, or a string.  Evaluates EXP by incrementing POS, and
Jan Kratochvil 72aed9d
+   writes the content from the elt stack into a local struct.  NARGS
Jan Kratochvil 72aed9d
+   specifies number of literal or range arguments the user provided.
Jan Kratochvil 72aed9d
+   NARGS must be the same number as ARRAY has dimensions.  */
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
 static struct value *
Jan Kratochvil 72aed9d
-value_f90_subarray (struct value *array,
Jan Kratochvil 72aed9d
-		    struct expression *exp, int *pos, enum noside noside)
Jan Kratochvil 72aed9d
+value_f90_subarray (struct value *array, struct expression *exp,
Jan Kratochvil 72aed9d
+		    int *pos, int nargs, enum noside noside)
Jan Kratochvil 72aed9d
 {
Jan Kratochvil 72aed9d
-  int pc = (*pos) + 1;
0702d0d
-  LONGEST low_bound, high_bound;
Jan Kratochvil 72aed9d
-  struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
Jan Kratochvil 72aed9d
-  enum range_type range_type
Jan Kratochvil 72aed9d
-    = (enum range_type) longest_to_int (exp->elts[pc].longconst);
Jan Kratochvil 72aed9d
- 
Jan Kratochvil 72aed9d
-  *pos += 3;
f637971
-
f637971
-  if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
f637971
-    low_bound = TYPE_LOW_BOUND (range);
f637971
-  else
f637971
-    low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
0702d0d
+  int i, dim_count = 0;
Jan Kratochvil 72aed9d
+  struct value *new_array = array;
Jan Kratochvil 72aed9d
+  struct type *array_type = check_typedef (value_type (new_array));
Jan Kratochvil 72aed9d
+  struct type *elt_type;
Jan Kratochvil 72aed9d
+
a3b5cf4
+  typedef struct
Jan Kratochvil 72aed9d
+  {
Jan Kratochvil 72aed9d
+    enum range_type f90_range_type;
Jan Kratochvil 72aed9d
+    LONGEST low, high, stride;
Jan Kratochvil 72aed9d
+  } subscript_range;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  typedef enum subscript_kind
Jan Kratochvil 72aed9d
+  {
Jan Kratochvil 72aed9d
+    SUBSCRIPT_RANGE,    /* e.g. "(lowbound:highbound)"  */
Jan Kratochvil 72aed9d
+    SUBSCRIPT_INDEX    /* e.g. "(literal)"  */
Jan Kratochvil 72aed9d
+  } kind;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Local struct to hold user data for Fortran subarray dimensions.  */
Jan Kratochvil 72aed9d
+  struct subscript_store
Jan Kratochvil 72aed9d
+  {
Jan Kratochvil 72aed9d
+    /* For every dimension, we are either working on a range or an index
Jan Kratochvil 72aed9d
+       expression, so we store this info separately for later.  */
Jan Kratochvil 72aed9d
+    enum subscript_kind kind;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+    /* We also store either the lower and upper bound info, or the index
Jan Kratochvil 72aed9d
+       number.  Before evaluation of the input values, we do not know if we are
Jan Kratochvil 72aed9d
+       actually working on a range of ranges, or an index in a range.  So as a
Jan Kratochvil 72aed9d
+       first step we store all input in a union.  The array calculation itself
Jan Kratochvil 72aed9d
+       deals with this later on.  */
Jan Kratochvil 72aed9d
+    union element_range
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      subscript_range range;
Jan Kratochvil 72aed9d
+      LONGEST number;
Jan Kratochvil 72aed9d
+    } U;
Jan Kratochvil 72aed9d
+  } *subscript_array;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Check if the number of arguments provided by the user matches
Jan Kratochvil 72aed9d
+     the number of dimension of the array.  A string has only one
Jan Kratochvil 72aed9d
+     dimension.  */
Jan Kratochvil 72aed9d
+  if (nargs != calc_f77_array_dims (value_type (new_array)))
Jan Kratochvil 72aed9d
+    error (_("Wrong number of subscripts"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  subscript_array = (struct subscript_store*) alloca (sizeof (*subscript_array) * nargs);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Parse the user input into the SUBSCRIPT_ARRAY to store it.  We need
Jan Kratochvil 72aed9d
+     to evaluate it first, as the input is from left-to-right.  The
Jan Kratochvil 72aed9d
+     array is stored from right-to-left.  So we have to use the user
Jan Kratochvil 72aed9d
+     input in reverse order.  Later on, we need the input information to
Jan Kratochvil 72aed9d
+     re-calculate the output array.  For multi-dimensional arrays, we
Jan Kratochvil 72aed9d
+     can be dealing with any possible combination of ranges and indices
Jan Kratochvil 72aed9d
+     for every dimension.  */
Jan Kratochvil 72aed9d
+  for (i = 0; i < nargs; i++)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      struct subscript_store *index = &subscript_array[i];
a3b5cf4
+
Jan Kratochvil 72aed9d
+      /* The user input is a range, with or without lower and upper bound.
Jan Kratochvil 72aed9d
+	 E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc.  */
Jan Kratochvil 72aed9d
+      if (exp->elts[*pos].opcode == OP_RANGE)
Jan Kratochvil 72aed9d
+	{
Jan Kratochvil 72aed9d
+	  int pc = (*pos) + 1;
Jan Kratochvil 72aed9d
+	  subscript_range *range;
f637971
+
Jan Kratochvil 72aed9d
+	  index->kind = SUBSCRIPT_RANGE;
Jan Kratochvil 72aed9d
+	  range = &index->U.range;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  *pos += 3;
Jan Kratochvil 72aed9d
+	  range->f90_range_type = (enum range_type) exp->elts[pc].longconst;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  /* If a lower bound was provided by the user, the bit has been
Jan Kratochvil 72aed9d
+	     set and we can assign the value from the elt stack.  Same for
Jan Kratochvil 72aed9d
+	     upper bound.  */
Jan Kratochvil 72aed9d
+	  if ((range->f90_range_type & SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
+	      == SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
+	    range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp,
Jan Kratochvil 72aed9d
+							 pos, noside));
Jan Kratochvil 72aed9d
+	  if ((range->f90_range_type & SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
+	      == SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
+	    range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
Jan Kratochvil 72aed9d
+							  pos, noside));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  /* Assign the user's stride value if provided.  */
Jan Kratochvil 72aed9d
+	  if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
Jan Kratochvil 72aed9d
+	    range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
Jan Kratochvil 72aed9d
+							     pos, noside));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  /* Assign the default stride value '1'.  */
Jan Kratochvil 72aed9d
+	  else
Jan Kratochvil 72aed9d
+	    range->stride = 1;
a3b5cf4
 
a3b5cf4
-  if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
a3b5cf4
-    high_bound = TYPE_HIGH_BOUND (range);
a3b5cf4
-  else
a3b5cf4
-    high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
Jan Kratochvil 72aed9d
+	  /* Check the provided stride value is illegal, aka '0'.  */
Jan Kratochvil 72aed9d
+	  if (range->stride == 0)
Jan Kratochvil 72aed9d
+	    error (_("Stride must not be 0"));
Jan Kratochvil 72aed9d
+	}
Jan Kratochvil 72aed9d
+      /* User input is an index.  E.g.: "p arry(5)".  */
Jan Kratochvil 72aed9d
+      else
Jan Kratochvil 72aed9d
+	{
Jan Kratochvil 72aed9d
+	  struct value *val;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  index->kind = SUBSCRIPT_INDEX;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  /* Evaluate each subscript; it must be a legal integer in F77.  This
Jan Kratochvil 72aed9d
+	     ensures the validity of the provided index.  */
Jan Kratochvil 72aed9d
+	  val = evaluate_subexp_with_coercion (exp, pos, noside);
Jan Kratochvil 72aed9d
+	  index->U.number = value_as_long (val);
Jan Kratochvil 72aed9d
+	}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Traverse the array from right to left and set the high and low bounds
Jan Kratochvil 72aed9d
+     for later use.  */
Jan Kratochvil 72aed9d
+  for (i = nargs - 1; i >= 0; i--)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      struct subscript_store *index = &subscript_array[i];
Jan Kratochvil 72aed9d
+      struct type *index_type = TYPE_INDEX_TYPE (array_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      switch (index->kind)
Jan Kratochvil 72aed9d
+	{
Jan Kratochvil 72aed9d
+	case SUBSCRIPT_RANGE:
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* When we hit the first range specified by the user, we must
Jan Kratochvil 72aed9d
+	       treat any subsequent user entry as a range.  We simply
Jan Kratochvil 72aed9d
+	       increment DIM_COUNT which tells us how many times we are
Jan Kratochvil 72aed9d
+	       calling VALUE_SLICE_1.  */
Jan Kratochvil 72aed9d
+	    subscript_range *range = &index->U.range;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* If no lower bound was provided by the user, we take the
Jan Kratochvil 72aed9d
+	       default boundary.  Same for the high bound.  */
Jan Kratochvil 72aed9d
+	    if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0)
Jan Kratochvil 72aed9d
+	      range->low = TYPE_LOW_BOUND (index_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0)
Jan Kratochvil 72aed9d
+	      range->high = TYPE_HIGH_BOUND (index_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* Both user provided low and high bound have to be inside the
Jan Kratochvil 72aed9d
+	       array bounds.  Throw an error if not.  */
Jan Kratochvil 72aed9d
+	    if (range->low < TYPE_LOW_BOUND (index_type)
Jan Kratochvil 72aed9d
+		|| range->low > TYPE_HIGH_BOUND (index_type)
Jan Kratochvil 72aed9d
+		|| range->high < TYPE_LOW_BOUND (index_type)
Jan Kratochvil 72aed9d
+		|| range->high > TYPE_HIGH_BOUND (index_type))
Jan Kratochvil 72aed9d
+	      error (_("provided bound(s) outside array bound(s)"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* For a negative stride the lower boundary must be larger than the
Jan Kratochvil 72aed9d
+	       upper boundary.
Jan Kratochvil 72aed9d
+	       For a positive stride the lower boundary must be smaller than the
Jan Kratochvil 72aed9d
+	       upper boundary.  */
Jan Kratochvil 72aed9d
+	    if ((range->stride < 0 && range->low < range->high)
Jan Kratochvil 72aed9d
+		|| (range->stride > 0 && range->low > range->high))
Jan Kratochvil 72aed9d
+	      error (_("Wrong value provided for stride and boundaries"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
+	  break;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	case SUBSCRIPT_INDEX:
Jan Kratochvil 72aed9d
+	  break;
f637971
+
Jan Kratochvil 72aed9d
+	}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+       array_type = TYPE_TARGET_TYPE (array_type);
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Reset ARRAY_TYPE before slicing.*/
Jan Kratochvil 72aed9d
+  array_type = check_typedef (value_type (new_array));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Traverse the array from right to left and evaluate each corresponding
Jan Kratochvil 72aed9d
+     user input.  VALUE_SUBSCRIPT is called for every index, until a range
Jan Kratochvil 72aed9d
+     expression is evaluated.  After a range expression has been evaluated,
Jan Kratochvil 72aed9d
+     every subsequent expression is also treated as a range.  */
Jan Kratochvil 72aed9d
+  for (i = nargs - 1; i >= 0; i--)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      struct subscript_store *index = &subscript_array[i];
Jan Kratochvil 72aed9d
+      struct type *index_type = TYPE_INDEX_TYPE (array_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      switch (index->kind)
Jan Kratochvil 72aed9d
+	{
Jan Kratochvil 72aed9d
+	case SUBSCRIPT_RANGE:
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* When we hit the first range specified by the user, we must
Jan Kratochvil 72aed9d
+	       treat any subsequent user entry as a range.  We simply
Jan Kratochvil 72aed9d
+	       increment DIM_COUNT which tells us how many times we are
Jan Kratochvil 72aed9d
+	       calling VALUE_SLICE_1.  */
Jan Kratochvil 72aed9d
+	    subscript_range *range = &index->U.range;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* DIM_COUNT counts every user argument that is treated as a range.
Jan Kratochvil 72aed9d
+	       This is necessary for expressions like 'print array(7, 8:9).
Jan Kratochvil 72aed9d
+	       Here the first argument is a literal, but must be treated as a
Jan Kratochvil 72aed9d
+	       range argument to allow the correct output representation.  */
Jan Kratochvil 72aed9d
+	    dim_count++;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    new_array
Jan Kratochvil 72aed9d
+	      = value_slice_1 (new_array, range->low,
Jan Kratochvil 72aed9d
+			       range->high - range->low + 1,
Jan Kratochvil 72aed9d
+			       range->stride, dim_count);
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
+	  break;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	case SUBSCRIPT_INDEX:
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+	    /* DIM_COUNT only stays '0' when no range argument was processed
Jan Kratochvil 72aed9d
+	       before, starting from the last dimension.  This way we can
Jan Kratochvil 72aed9d
+	       reduce the number of dimensions from the result array.
Jan Kratochvil 72aed9d
+	       However, if a range has been processed before an index, we
Jan Kratochvil 72aed9d
+	       treat the index like a range with equal low- and high bounds
Jan Kratochvil 72aed9d
+	       to get the value offset right.  */
Jan Kratochvil 72aed9d
+	    if (dim_count == 0)
Jan Kratochvil 72aed9d
+	      new_array
Jan Kratochvil 72aed9d
+	        = value_subscripted_rvalue (new_array, index->U.number,
Jan Kratochvil 72aed9d
+					    f77_get_lowerbound (value_type
Jan Kratochvil 72aed9d
+								  (new_array)));
Jan Kratochvil 72aed9d
+	    else
Jan Kratochvil 72aed9d
+	      {
Jan Kratochvil 72aed9d
+		dim_count++;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+		/* We might end up here, because we have to treat the provided
Jan Kratochvil 72aed9d
+		   index like a range. But now VALUE_SUBSCRIPTED_RVALUE
Jan Kratochvil 72aed9d
+		   cannot do the range checks for us. So we have to make sure
Jan Kratochvil 72aed9d
+		   ourselves that the user provided index is inside the
Jan Kratochvil 72aed9d
+		   array bounds.  Throw an error if not.  */
Jan Kratochvil 72aed9d
+		if (index->U.number < TYPE_LOW_BOUND (index_type)
Jan Kratochvil 72aed9d
+		    && index->U.number > TYPE_HIGH_BOUND (index_type))
Jan Kratochvil 72aed9d
+		  error (_("provided bound(s) outside array bound(s)"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+		if (index->U.number > TYPE_LOW_BOUND (index_type)
Jan Kratochvil 72aed9d
+		    && index->U.number > TYPE_HIGH_BOUND (index_type))
Jan Kratochvil 72aed9d
+		  error (_("provided bound(s) outside array bound(s)"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+		new_array = value_slice_1 (new_array,
Jan Kratochvil 72aed9d
+					   index->U.number,
Jan Kratochvil 72aed9d
+					   1, /* COUNT is '1' element  */
Jan Kratochvil 72aed9d
+					   1, /* STRIDE set to '1'  */
Jan Kratochvil 72aed9d
+					   dim_count);
Jan Kratochvil 72aed9d
+	      }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
+	  break;
Jan Kratochvil 72aed9d
+	}
Jan Kratochvil 72aed9d
+      array_type = TYPE_TARGET_TYPE (array_type);
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* With DIM_COUNT > 1 we currently have a one dimensional array, but expect
Jan Kratochvil 72aed9d
+     an array of arrays, depending on how many ranges have been provided by
Jan Kratochvil 72aed9d
+     the user.  So we need to rebuild the array dimensions for printing it
Jan Kratochvil 72aed9d
+     correctly.
Jan Kratochvil 72aed9d
+     Starting from right to left in the user input, after we hit the first
Jan Kratochvil 72aed9d
+     range argument every subsequent argument is also treated as a range.
Jan Kratochvil 72aed9d
+     E.g.:
Jan Kratochvil 72aed9d
+     "p ary(3, 7, 2:15)" in Fortran has only 1 dimension, but we calculated 3
Jan Kratochvil 72aed9d
+     ranges.
Jan Kratochvil 72aed9d
+     "p ary(3, 7:12, 4)" in Fortran has only 1 dimension, but we calculated 2
Jan Kratochvil 72aed9d
+     ranges.
Jan Kratochvil 72aed9d
+     "p ary(2:4, 5, 7)" in Fortran has only 1 dimension, and we calculated 1
Jan Kratochvil 72aed9d
+     range.  */
Jan Kratochvil 72aed9d
+  if (dim_count > 1)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      struct value *v = NULL;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      elt_type = TYPE_TARGET_TYPE (value_type (new_array));
a3b5cf4
 
a3b5cf4
-  return value_slice (array, low_bound, high_bound - low_bound + 1);
Jan Kratochvil 72aed9d
+      /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in
Jan Kratochvil 72aed9d
+	 the output array.  So we traverse the SUBSCRIPT_ARRAY again, looking
Jan Kratochvil 72aed9d
+	 for a range entry.  When we find one, we use the range info to create
Jan Kratochvil 72aed9d
+	 an additional range_type to set the correct bounds and dimensions for
Jan Kratochvil 72aed9d
+	 the output array.  In addition, we may have a stride value that is not
Jan Kratochvil 72aed9d
+	 '1', forcing us to adjust the number of elements in a range, according
Jan Kratochvil 72aed9d
+	 to the stride value.  */
Jan Kratochvil 72aed9d
+      for (i = 0; i < nargs; i++)
Jan Kratochvil 72aed9d
+	{
Jan Kratochvil 72aed9d
+	  struct subscript_store *index = &subscript_array[i];
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	  if (index->kind == SUBSCRIPT_RANGE)
Jan Kratochvil 72aed9d
+	    {
Jan Kratochvil 72aed9d
+	      struct type *range_type, *interim_array_type;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      int new_length;
a3b5cf4
+
Jan Kratochvil 72aed9d
+	      /* The length of a sub-dimension with all elements between the
Jan Kratochvil 72aed9d
+		 bounds plus the start element itself.  It may be modified by
Jan Kratochvil 72aed9d
+		 a user provided stride value.  */
Jan Kratochvil 72aed9d
+	      new_length = index->U.range.high - index->U.range.low;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      new_length /= index->U.range.stride;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      range_type
Jan Kratochvil 72aed9d
+		= create_static_range_type (NULL,
Jan Kratochvil 72aed9d
+					    elt_type,
Jan Kratochvil 72aed9d
+					    index->U.range.low,
Jan Kratochvil 72aed9d
+					    index->U.range.low + new_length);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      interim_array_type = create_array_type (NULL,
Jan Kratochvil 72aed9d
+						      elt_type,
Jan Kratochvil 72aed9d
+						      range_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      TYPE_CODE (interim_array_type)
Jan Kratochvil 72aed9d
+		= TYPE_CODE (value_type (new_array));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      v = allocate_value (interim_array_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	      elt_type = value_type (v);
Jan Kratochvil 72aed9d
+	    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	}
Jan Kratochvil 72aed9d
+      value_contents_copy (v, 0, new_array, 0, TYPE_LENGTH (elt_type));
Jan Kratochvil 72aed9d
+      return v;
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  return new_array;
Jan Kratochvil 72aed9d
 }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 
0a2f2a5
@@ -1235,19 +1530,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
a3b5cf4
   return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
a3b5cf4
 }
a3b5cf4
 
a3b5cf4
-/* Helper for skipping all the arguments in an undetermined argument list.
a3b5cf4
-   This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
a3b5cf4
-   case of evaluate_subexp_standard as multiple, but not all, code paths
a3b5cf4
-   require a generic skip.  */
a3b5cf4
-
a3b5cf4
-static void
a3b5cf4
-skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
a3b5cf4
-			   enum noside noside)
a3b5cf4
-{
a3b5cf4
-  for (int i = 0; i < nargs; ++i)
a3b5cf4
-    evaluate_subexp (NULL_TYPE, exp, pos, noside);
a3b5cf4
-}
a3b5cf4
-
a3b5cf4
 struct value *
a3b5cf4
 evaluate_subexp_standard (struct type *expect_type,
a3b5cf4
 			  struct expression *exp, int *pos,
0a2f2a5
@@ -1942,33 +2224,8 @@ evaluate_subexp_standard (struct type *expect_type,
Jan Kratochvil 72aed9d
       switch (code)
Jan Kratochvil 72aed9d
 	{
Jan Kratochvil 72aed9d
 	case TYPE_CODE_ARRAY:
Jan Kratochvil 72aed9d
-	  if (exp->elts[*pos].opcode == OP_RANGE)
Jan Kratochvil 72aed9d
-	    return value_f90_subarray (arg1, exp, pos, noside);
Jan Kratochvil 72aed9d
-	  else
a3b5cf4
-	    {
a3b5cf4
-	      if (noside == EVAL_SKIP)
a3b5cf4
-		{
a3b5cf4
-		  skip_undetermined_arglist (nargs, exp, pos, noside);
a3b5cf4
-		  /* Return the dummy value with the correct type.  */
a3b5cf4
-		  return arg1;
a3b5cf4
-		}
a3b5cf4
-	      goto multi_f77_subscript;
a3b5cf4
-	    }
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
 	case TYPE_CODE_STRING:
Jan Kratochvil 72aed9d
-	  if (exp->elts[*pos].opcode == OP_RANGE)
Jan Kratochvil 72aed9d
-	    return value_f90_subarray (arg1, exp, pos, noside);
Jan Kratochvil 72aed9d
-	  else
Jan Kratochvil 72aed9d
-	    {
a3b5cf4
-	      if (noside == EVAL_SKIP)
a3b5cf4
-		{
a3b5cf4
-		  skip_undetermined_arglist (nargs, exp, pos, noside);
a3b5cf4
-		  /* Return the dummy value with the correct type.  */
a3b5cf4
-		  return arg1;
a3b5cf4
-		}
Jan Kratochvil 72aed9d
-	      arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
Jan Kratochvil 72aed9d
-	      return value_subscript (arg1, value_as_long (arg2));
Jan Kratochvil 72aed9d
-	    }
Jan Kratochvil 72aed9d
+	  return value_f90_subarray (arg1, exp, pos, nargs, noside);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 	case TYPE_CODE_PTR:
Jan Kratochvil 72aed9d
 	case TYPE_CODE_FUNC:
99dc38b
@@ -2388,49 +2645,6 @@ evaluate_subexp_standard (struct type *expect_type,
Jan Kratochvil 72aed9d
 	}
Jan Kratochvil 72aed9d
       return (arg1);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-    multi_f77_subscript:
Jan Kratochvil 72aed9d
-      {
Jan Kratochvil 72aed9d
-	LONGEST subscript_array[MAX_FORTRAN_DIMS];
Jan Kratochvil 72aed9d
-	int ndimensions = 1, i;
Jan Kratochvil 72aed9d
-	struct value *array = arg1;
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	if (nargs > MAX_FORTRAN_DIMS)
Jan Kratochvil 72aed9d
-	  error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	ndimensions = calc_f77_array_dims (type);
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	if (nargs != ndimensions)
Jan Kratochvil 72aed9d
-	  error (_("Wrong number of subscripts"));
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	gdb_assert (nargs > 0);
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	/* Now that we know we have a legal array subscript expression 
Jan Kratochvil 72aed9d
-	   let us actually find out where this element exists in the array.  */
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	/* Take array indices left to right.  */
Jan Kratochvil 72aed9d
-	for (i = 0; i < nargs; i++)
Jan Kratochvil 72aed9d
-	  {
Jan Kratochvil 72aed9d
-	    /* Evaluate each subscript; it must be a legal integer in F77.  */
Jan Kratochvil 72aed9d
-	    arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	    /* Fill in the subscript array.  */
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	    subscript_array[i] = value_as_long (arg2);
Jan Kratochvil 72aed9d
-	  }
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	/* Internal type of array is arranged right to left.  */
Jan Kratochvil 72aed9d
-	for (i = nargs; i > 0; i--)
Jan Kratochvil 72aed9d
-	  {
Jan Kratochvil 72aed9d
-	    struct type *array_type = check_typedef (value_type (array));
Jan Kratochvil 72aed9d
-	    LONGEST index = subscript_array[i - 1];
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	    array = value_subscripted_rvalue (array, index,
Jan Kratochvil 72aed9d
-					      f77_get_lowerbound (array_type));
Jan Kratochvil 72aed9d
-	  }
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
-	return array;
Jan Kratochvil 72aed9d
-      }
Jan Kratochvil 72aed9d
-
Jan Kratochvil 72aed9d
     case BINOP_LOGICAL_AND:
Jan Kratochvil 72aed9d
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
Jan Kratochvil 72aed9d
       if (noside == EVAL_SKIP)
99dc38b
@@ -3350,6 +3564,9 @@ calc_f77_array_dims (struct type *array_type)
Jan Kratochvil 72aed9d
   int ndimen = 1;
Jan Kratochvil 72aed9d
   struct type *tmp_type;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
+  if (TYPE_CODE (array_type) == TYPE_CODE_STRING)
Jan Kratochvil 72aed9d
+    return 1;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
   if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
Jan Kratochvil 72aed9d
     error (_("Can't get dimensions for a non-array type"));
Jan Kratochvil 72aed9d
 
f637971
diff --git a/gdb/expprint.c b/gdb/expprint.c
f637971
--- a/gdb/expprint.c
f637971
+++ b/gdb/expprint.c
2f578f5
@@ -580,17 +580,14 @@ print_subexp_standard (struct expression *exp, int *pos,
2bcd68d
 	  longest_to_int (exp->elts[pc + 1].longconst);
Jan Kratochvil 72aed9d
 	*pos += 2;
Jan Kratochvil 72aed9d
 
2bcd68d
-	if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE
2bcd68d
-	    || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE)
2bcd68d
+	if ((range_type & SUBARRAY_HIGH_BOUND_EXCLUSIVE)
2bcd68d
+	    == SUBARRAY_HIGH_BOUND_EXCLUSIVE)
2bcd68d
 	  fputs_filtered ("EXCLUSIVE_", stream);
Jan Kratochvil 72aed9d
 	fputs_filtered ("RANGE(", stream);
Jan Kratochvil 72aed9d
-	if (range_type == HIGH_BOUND_DEFAULT
2bcd68d
-	    || range_type == NONE_BOUND_DEFAULT
2bcd68d
-	    || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE)
Jan Kratochvil 72aed9d
+	if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
Jan Kratochvil 72aed9d
 	fputs_filtered ("..", stream);
Jan Kratochvil 72aed9d
-	if (range_type == LOW_BOUND_DEFAULT
Jan Kratochvil 72aed9d
-	    || range_type == NONE_BOUND_DEFAULT)
Jan Kratochvil 72aed9d
+	if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
Jan Kratochvil 72aed9d
 	fputs_filtered (")", stream);
Jan Kratochvil 72aed9d
 	return;
2f578f5
@@ -1107,22 +1104,24 @@ dump_subexp_body_standard (struct expression *exp,
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 	switch (range_type)
Jan Kratochvil 72aed9d
 	  {
Jan Kratochvil 72aed9d
-	  case BOTH_BOUND_DEFAULT:
Jan Kratochvil 72aed9d
+	  case SUBARRAY_NONE_BOUND:
Jan Kratochvil 72aed9d
 	    fputs_filtered ("Range '..'", stream);
Jan Kratochvil 72aed9d
 	    break;
Jan Kratochvil 72aed9d
-	  case LOW_BOUND_DEFAULT:
Jan Kratochvil 72aed9d
+	  case SUBARRAY_HIGH_BOUND:
Jan Kratochvil 72aed9d
 	    fputs_filtered ("Range '..EXP'", stream);
Jan Kratochvil 72aed9d
 	    break;
2bcd68d
-	  case LOW_BOUND_DEFAULT_EXCLUSIVE:
2bcd68d
-	    fputs_filtered ("ExclusiveRange '..EXP'", stream);
2bcd68d
-	    break;
Jan Kratochvil 72aed9d
-	  case HIGH_BOUND_DEFAULT:
Jan Kratochvil 72aed9d
+	  case SUBARRAY_LOW_BOUND:
Jan Kratochvil 72aed9d
 	    fputs_filtered ("Range 'EXP..'", stream);
Jan Kratochvil 72aed9d
 	    break;
Jan Kratochvil 72aed9d
-	  case NONE_BOUND_DEFAULT:
2bcd68d
+	  case (SUBARRAY_LOW_BOUND
2bcd68d
+		| SUBARRAY_HIGH_BOUND
2bcd68d
+		| SUBARRAY_HIGH_BOUND_EXCLUSIVE):
2bcd68d
+	    fputs_filtered ("ExclusiveRange '..EXP'", stream);
2bcd68d
+	    break;
Jan Kratochvil 72aed9d
+	  case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND):
Jan Kratochvil 72aed9d
 	    fputs_filtered ("Range 'EXP..EXP'", stream);
Jan Kratochvil 72aed9d
 	    break;
2bcd68d
-	  case NONE_BOUND_DEFAULT_EXCLUSIVE:
2bcd68d
+	  case (SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE):
2bcd68d
 	    fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
2bcd68d
 	    break;
Jan Kratochvil 72aed9d
 	  default:
2f578f5
@@ -1130,11 +1129,9 @@ dump_subexp_body_standard (struct expression *exp,
Jan Kratochvil 72aed9d
 	    break;
Jan Kratochvil 72aed9d
 	  }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-	if (range_type == HIGH_BOUND_DEFAULT
Jan Kratochvil 72aed9d
-	    || range_type == NONE_BOUND_DEFAULT)
Jan Kratochvil 72aed9d
+	if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
 	  elt = dump_subexp (exp, stream, elt);
Jan Kratochvil 72aed9d
-	if (range_type == LOW_BOUND_DEFAULT
Jan Kratochvil 72aed9d
-	    || range_type == NONE_BOUND_DEFAULT)
Jan Kratochvil 72aed9d
+	if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
 	  elt = dump_subexp (exp, stream, elt);
Jan Kratochvil 72aed9d
       }
Jan Kratochvil 72aed9d
       break;
f637971
diff --git a/gdb/expression.h b/gdb/expression.h
f637971
--- a/gdb/expression.h
f637971
+++ b/gdb/expression.h
f7760f8
@@ -167,28 +167,27 @@ extern void dump_raw_expression (struct expression *,
Jan Kratochvil 5bb0f3b
 				 struct ui_file *, const char *);
Jan Kratochvil 72aed9d
 extern void dump_prefix_expression (struct expression *, struct ui_file *);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-/* In an OP_RANGE expression, either bound could be empty, indicating
Jan Kratochvil 72aed9d
-   that its value is by default that of the corresponding bound of the
2bcd68d
-   array or string.  Also, the upper end of the range can be exclusive
2bcd68d
-   or inclusive.  So we have six sorts of subrange.  This enumeration
2bcd68d
-   type is to identify this.  */
2bcd68d
+/* In an OP_RANGE expression, either bound can be provided by the
2bcd68d
+   user, or not.  In addition to this, the user can also specify a
2bcd68d
+   stride value to indicated only certain elements of the array.
2bcd68d
+   Also, the upper end of the range can be exclusive or inclusive.
2bcd68d
+   This enumeration type is to identify this.  */
2bcd68d
 
Jan Kratochvil 72aed9d
 enum range_type
2bcd68d
-{
2bcd68d
-  /* Neither the low nor the high bound was given -- so this refers to
2bcd68d
-     the entire available range.  */
2bcd68d
-  BOTH_BOUND_DEFAULT,
2bcd68d
-  /* The low bound was not given and the high bound is inclusive.  */
2bcd68d
-  LOW_BOUND_DEFAULT,
2bcd68d
-  /* The high bound was not given and the low bound in inclusive.  */
2bcd68d
-  HIGH_BOUND_DEFAULT,
2bcd68d
-  /* Both bounds were given and both are inclusive.  */
2bcd68d
-  NONE_BOUND_DEFAULT,
2bcd68d
-  /* The low bound was not given and the high bound is exclusive.  */
2bcd68d
-  NONE_BOUND_DEFAULT_EXCLUSIVE,
2bcd68d
-  /* Both bounds were given.  The low bound is inclusive and the high
2bcd68d
-     bound is exclusive.  */
2bcd68d
-  LOW_BOUND_DEFAULT_EXCLUSIVE,
2bcd68d
-};
2bcd68d
+  {
Jan Kratochvil 72aed9d
+    SUBARRAY_NONE_BOUND = 0x0,		/* "( : )"  */
Jan Kratochvil 72aed9d
+    SUBARRAY_LOW_BOUND = 0x1,		/* "(low:)"  */
Jan Kratochvil 72aed9d
+    SUBARRAY_HIGH_BOUND = 0x2,		/* "(:high)"  */
2bcd68d
+    SUBARRAY_STRIDE = 0x4,		/* "(::stride)"  */
2bcd68d
+    /* The low bound was not given and the high bound is exclusive.
2bcd68d
+       In this case we always use (SUBARRAY_HIGH_BOUND |
2bcd68d
+       SUBARRAY_HIGH_BOUND_EXCLUSIVE).  */
2bcd68d
+    SUBARRAY_HIGH_BOUND_EXCLUSIVE = 0x8,
2bcd68d
+    /* Both bounds were given.  The low bound is inclusive and the high
2bcd68d
+       bound is exclusive.  In this case, we use (SUBARRAY_LOW_BOUND |
2bcd68d
+       SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE).  */
2bcd68d
+    // SUBARRAY_LOW_BOUND_EXCLUSIVE = (SUBARRAY_LOW_BOUND
2bcd68d
+    // 				    | SUBARRAY_HIGH_BOUND_EXCLUSIVE),
2bcd68d
+  };
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 #endif /* !defined (EXPRESSION_H) */
f637971
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
f637971
--- a/gdb/f-exp.y
f637971
+++ b/gdb/f-exp.y
a5d2c85
@@ -282,31 +282,63 @@ arglist :	subrange
Jan Kratochvil 72aed9d
    
Jan Kratochvil 72aed9d
 arglist	:	arglist ',' exp   %prec ABOVE_COMMA
e90857f
 			{ pstate->arglist_len++; }
Jan Kratochvil 72aed9d
+	|	arglist ',' subrange	%prec ABOVE_COMMA
e90857f
+			{ pstate->arglist_len++; }
Jan Kratochvil 72aed9d
 	;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 /* There are four sorts of subrange types in F90.  */
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 subrange:	exp ':' exp	%prec ABOVE_COMMA
Jan Kratochvil 72aed9d
-			{ write_exp_elt_opcode (pstate, OP_RANGE); 
Jan Kratochvil 72aed9d
-			  write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
Jan Kratochvil 72aed9d
+			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate,
Jan Kratochvil 72aed9d
+						 SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
Jan Kratochvil 72aed9d
 			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
 	;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 subrange:	exp ':'	%prec ABOVE_COMMA
Jan Kratochvil 72aed9d
 			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
-			  write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND);
Jan Kratochvil 72aed9d
 			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
 	;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 subrange:	':' exp	%prec ABOVE_COMMA
Jan Kratochvil 72aed9d
 			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
-			  write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND);
Jan Kratochvil 72aed9d
 			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
 	;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 subrange:	':'	%prec ABOVE_COMMA
Jan Kratochvil 72aed9d
 			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
-			  write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND);
Jan Kratochvil 72aed9d
+			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
+	;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+/* Each subrange type can have a stride argument.  */
Jan Kratochvil 72aed9d
+subrange:	exp ':' exp ':' exp %prec ABOVE_COMMA
Jan Kratochvil 72aed9d
+			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
Jan Kratochvil 72aed9d
+						 | SUBARRAY_HIGH_BOUND
Jan Kratochvil 72aed9d
+						 | SUBARRAY_STRIDE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
+	;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+subrange:	exp ':' ':' exp %prec ABOVE_COMMA
Jan Kratochvil 72aed9d
+			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
Jan Kratochvil 72aed9d
+						 | SUBARRAY_STRIDE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
+	;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+subrange:	':' exp ':' exp %prec ABOVE_COMMA
Jan Kratochvil 72aed9d
+			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
Jan Kratochvil 72aed9d
+						 | SUBARRAY_STRIDE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
+	;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+subrange:	':' ':' exp %prec ABOVE_COMMA
Jan Kratochvil 72aed9d
+			{ write_exp_elt_opcode (pstate, OP_RANGE);
Jan Kratochvil 72aed9d
+			  write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
Jan Kratochvil 72aed9d
 			  write_exp_elt_opcode (pstate, OP_RANGE); }
Jan Kratochvil 72aed9d
 	;
Jan Kratochvil 72aed9d
 
f637971
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
f637971
--- a/gdb/f-valprint.c
f637971
+++ b/gdb/f-valprint.c
a5d2c85
@@ -129,6 +129,11 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
a5d2c85
 	byte_stride = dim_size;
Jan Kratochvil 72aed9d
       size_t offs = 0;
a5d2c85
 
Jan Kratochvil 72aed9d
+      if (byte_stride)
Jan Kratochvil 72aed9d
+        dim_size = byte_stride;
Jan Kratochvil 72aed9d
+      else
Jan Kratochvil 72aed9d
+        dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
a5d2c85
+
Jan Kratochvil 72aed9d
       for (i = lowerbound;
Jan Kratochvil 72aed9d
 	   (i < upperbound + 1 && (*elts) < options->print_max);
a5d2c85
 	   i++)
f637971
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
f637971
--- a/gdb/gdbtypes.c
f637971
+++ b/gdb/gdbtypes.c
a5d2c85
@@ -936,7 +936,7 @@ create_range_type (struct type *result_type, struct type *index_type,
Jan Kratochvil 72aed9d
   TYPE_RANGE_DATA (result_type)->high = *high_bound;
0a2f2a5
   TYPE_RANGE_DATA (result_type)->bias = bias;
Jan Kratochvil 72aed9d
 
a5d2c85
-  /* Initialize the stride to be a constant, the value will already be zero
a5d2c85
+  /* bias the stride to be a constant, the value will already be zero
a5d2c85
      thanks to the use of TYPE_ZALLOC above.  */
a5d2c85
   TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST;
Jan Kratochvil 72aed9d
 
a5d2c85
@@ -1001,7 +1001,8 @@ create_static_range_type (struct type *result_type, struct type *index_type,
Jan Kratochvil 72aed9d
   high.kind = PROP_CONST;
Jan Kratochvil 72aed9d
   high.data.const_val = high_bound;
Jan Kratochvil 72aed9d
 
0a2f2a5
-  result_type = create_range_type (result_type, index_type, &low, &high, 0);
Jan Kratochvil 72aed9d
+  result_type = create_range_type (result_type, index_type,
a5d2c85
+                                   &low, &high, 0);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   return result_type;
Jan Kratochvil 72aed9d
 }
a5d2c85
@@ -1236,6 +1237,7 @@ create_array_type_with_stride (struct type *result_type,
Jan Kratochvil 72aed9d
       if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
Jan Kratochvil 72aed9d
 	low_bound = high_bound = 0;
Jan Kratochvil 72aed9d
       element_type = check_typedef (element_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
       /* Be careful when setting the array length.  Ada arrays can be
Jan Kratochvil 72aed9d
 	 empty arrays with the high_bound being smaller than the low_bound.
Jan Kratochvil 72aed9d
 	 In such cases, the array length should be zero.  */
f637971
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
f637971
--- a/gdb/gdbtypes.h
f637971
+++ b/gdb/gdbtypes.h
a5d2c85
@@ -803,7 +803,6 @@ struct main_type
Jan Kratochvil d258670
     /* * Union member used for range types.  */
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
     struct range_bounds *bounds;
Jan Kratochvil d258670
-
Jan Kratochvil 72aed9d
   } flds_bnds;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   /* * Slot to point to additional language-specific fields of this
a5d2c85
@@ -1365,6 +1364,15 @@ extern bool set_type_align (struct type *, ULONGEST);
a5d2c85
 #define TYPE_BIT_STRIDE(range_type) \
a5d2c85
   (TYPE_RANGE_DATA(range_type)->stride.data.const_val \
a5d2c85
    * (TYPE_RANGE_DATA(range_type)->flag_is_byte_stride ? 8 : 1))
Jan Kratochvil 72aed9d
+#define TYPE_BYTE_STRIDE(range_type) \
Jan Kratochvil 72aed9d
+  TYPE_RANGE_DATA(range_type)->stride.data.const_val
Jan Kratochvil 72aed9d
+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
Jan Kratochvil 72aed9d
+  TYPE_RANGE_DATA(range_type)->stride.data.locexpr
Jan Kratochvil 72aed9d
+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
Jan Kratochvil 72aed9d
+  TYPE_RANGE_DATA(range_type)->stride.data.loclist
Jan Kratochvil 72aed9d
+#define TYPE_BYTE_STRIDE_KIND(range_type) \
Jan Kratochvil 72aed9d
+  TYPE_RANGE_DATA(range_type)->stride.kind
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 /* Property accessors for the type data location.  */
Jan Kratochvil 72aed9d
 #define TYPE_DATA_LOCATION(thistype) \
a5d2c85
@@ -1400,6 +1408,9 @@ extern bool set_type_align (struct type *, ULONGEST);
Jan Kratochvil 72aed9d
    TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
Jan Kratochvil 72aed9d
 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
Jan Kratochvil 72aed9d
    TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
Jan Kratochvil 72aed9d
+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
Jan Kratochvil 72aed9d
+   (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
Jan Kratochvil 72aed9d
    (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
f637971
diff --git a/gdb/parse.c b/gdb/parse.c
f637971
--- a/gdb/parse.c
f637971
+++ b/gdb/parse.c
654fb50
@@ -919,24 +919,20 @@ operator_length_standard (const struct expression *expr, int endpos,
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
     case OP_RANGE:
Jan Kratochvil 72aed9d
       oplen = 3;
Jan Kratochvil 72aed9d
+      args = 0;
Jan Kratochvil 72aed9d
       range_type = (enum range_type)
Jan Kratochvil 72aed9d
 	longest_to_int (expr->elts[endpos - 2].longconst);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-      switch (range_type)
Jan Kratochvil 72aed9d
-	{
Jan Kratochvil 72aed9d
-	case LOW_BOUND_DEFAULT:
2bcd68d
-	case LOW_BOUND_DEFAULT_EXCLUSIVE:
Jan Kratochvil 72aed9d
-	case HIGH_BOUND_DEFAULT:
Jan Kratochvil 72aed9d
-	  args = 1;
Jan Kratochvil 72aed9d
-	  break;
Jan Kratochvil 72aed9d
-	case BOTH_BOUND_DEFAULT:
Jan Kratochvil 72aed9d
-	  args = 0;
Jan Kratochvil 72aed9d
-	  break;
Jan Kratochvil 72aed9d
-	case NONE_BOUND_DEFAULT:
2bcd68d
-	case NONE_BOUND_DEFAULT_EXCLUSIVE:
Jan Kratochvil 72aed9d
-	  args = 2;
Jan Kratochvil 72aed9d
-	  break;
Jan Kratochvil 72aed9d
-	}
Jan Kratochvil 72aed9d
+      /* Increment the argument counter for each argument
Jan Kratochvil 72aed9d
+	 provided by the user.  */
Jan Kratochvil 72aed9d
+      if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
+	args++;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
+	args++;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
Jan Kratochvil 72aed9d
+	args++;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
       break;
Jan Kratochvil 72aed9d
 
f637971
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
f637971
--- a/gdb/rust-exp.y
f637971
+++ b/gdb/rust-exp.y
2f578f5
@@ -2492,24 +2492,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
     case OP_RANGE:
Jan Kratochvil 72aed9d
       {
Jan Kratochvil 72aed9d
-	enum range_type kind = BOTH_BOUND_DEFAULT;
Jan Kratochvil 72aed9d
+	enum range_type kind = SUBARRAY_NONE_BOUND;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 	if (operation->left.op != NULL)
Jan Kratochvil 72aed9d
 	  {
0702d0d
 	    convert_ast_to_expression (operation->left.op, top);
Jan Kratochvil 72aed9d
-	    kind = HIGH_BOUND_DEFAULT;
Jan Kratochvil 72aed9d
+	    kind = SUBARRAY_LOW_BOUND;
Jan Kratochvil 72aed9d
 	  }
Jan Kratochvil 72aed9d
 	if (operation->right.op != NULL)
Jan Kratochvil 72aed9d
 	  {
0702d0d
 	    convert_ast_to_expression (operation->right.op, top);
Jan Kratochvil 72aed9d
-	    if (kind == BOTH_BOUND_DEFAULT)
2bcd68d
-	      kind = (operation->inclusive
2bcd68d
-		      ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
2bcd68d
+	    if (kind == SUBARRAY_NONE_BOUND)
2bcd68d
+	      {
2bcd68d
+		kind = (range_type) SUBARRAY_HIGH_BOUND;
2bcd68d
+		if (!operation->inclusive)
2bcd68d
+		  kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
2bcd68d
+	      }
2bcd68d
 	    else
2bcd68d
 	      {
Jan Kratochvil 72aed9d
-		gdb_assert (kind == HIGH_BOUND_DEFAULT);
2bcd68d
-		kind = (operation->inclusive
2bcd68d
-			? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE);
2bcd68d
+		gdb_assert (kind == SUBARRAY_LOW_BOUND);
2bcd68d
+		kind = (range_type) (kind | SUBARRAY_HIGH_BOUND);
2bcd68d
+		if (!operation->inclusive)
2bcd68d
+		  kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
2bcd68d
 	      }
Jan Kratochvil 72aed9d
 	  }
2bcd68d
 	else
f637971
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
f637971
--- a/gdb/rust-lang.c
f637971
+++ b/gdb/rust-lang.c
2f578f5
@@ -1224,13 +1224,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
Jan Kratochvil 72aed9d
   kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
Jan Kratochvil 72aed9d
   *pos += 3;
Jan Kratochvil 72aed9d
 
2bcd68d
-  if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
2bcd68d
-      || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
Jan Kratochvil 72aed9d
+  if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
Jan Kratochvil 72aed9d
     low = evaluate_subexp (NULL_TYPE, exp, pos, noside);
2bcd68d
-  if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
2bcd68d
-      || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
Jan Kratochvil 72aed9d
+  if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
     high = evaluate_subexp (NULL_TYPE, exp, pos, noside);
2bcd68d
-  bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
2bcd68d
+  bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE));
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   if (noside == EVAL_SKIP)
2bcd68d
     return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
2f578f5
@@ -1319,7 +1317,7 @@ rust_compute_range (struct type *type, struct value *range,
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   *low = 0;
Jan Kratochvil 72aed9d
   *high = 0;
Jan Kratochvil 72aed9d
-  *kind = BOTH_BOUND_DEFAULT;
Jan Kratochvil 72aed9d
+  *kind = SUBARRAY_NONE_BOUND;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   if (TYPE_NFIELDS (type) == 0)
Jan Kratochvil 72aed9d
     return;
2f578f5
@@ -1327,15 +1325,14 @@ rust_compute_range (struct type *type, struct value *range,
Jan Kratochvil 72aed9d
   i = 0;
Jan Kratochvil 72aed9d
   if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
Jan Kratochvil 72aed9d
     {
Jan Kratochvil 72aed9d
-      *kind = HIGH_BOUND_DEFAULT;
Jan Kratochvil 72aed9d
+      *kind = SUBARRAY_LOW_BOUND;
Jan Kratochvil 72aed9d
       *low = value_as_long (value_field (range, 0));
Jan Kratochvil 72aed9d
       ++i;
Jan Kratochvil 72aed9d
     }
Jan Kratochvil 72aed9d
   if (TYPE_NFIELDS (type) > i
Jan Kratochvil 72aed9d
       && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
Jan Kratochvil 72aed9d
     {
Jan Kratochvil 72aed9d
-      *kind = (*kind == BOTH_BOUND_DEFAULT
Jan Kratochvil 72aed9d
-	       ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT);
Jan Kratochvil 72aed9d
+      *kind = (range_type) (*kind | SUBARRAY_HIGH_BOUND);
Jan Kratochvil 72aed9d
       *high = value_as_long (value_field (range, i));
2bcd68d
 
2bcd68d
       if (rust_inclusive_range_type_p (type))
2f578f5
@@ -1353,7 +1350,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
Jan Kratochvil 72aed9d
   struct type *rhstype;
Jan Kratochvil 72aed9d
   LONGEST low, high_bound;
Jan Kratochvil 72aed9d
   /* Initialized to appease the compiler.  */
Jan Kratochvil 72aed9d
-  enum range_type kind = BOTH_BOUND_DEFAULT;
Jan Kratochvil 72aed9d
+  enum range_type kind = SUBARRAY_NONE_BOUND;
Jan Kratochvil 72aed9d
   LONGEST high = 0;
Jan Kratochvil 72aed9d
   int want_slice = 0;
Jan Kratochvil 72aed9d
 
2f578f5
@@ -1451,7 +1448,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
Jan Kratochvil 72aed9d
 	error (_("Cannot subscript non-array type"));
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
       if (want_slice
Jan Kratochvil 72aed9d
-	  && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT))
Jan Kratochvil 72aed9d
+	  && ((kind & SUBARRAY_LOW_BOUND) != SUBARRAY_LOW_BOUND))
Jan Kratochvil 72aed9d
 	low = low_bound;
Jan Kratochvil 72aed9d
       if (low < 0)
Jan Kratochvil 72aed9d
 	error (_("Index less than zero"));
2f578f5
@@ -1469,7 +1466,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
Jan Kratochvil 72aed9d
 	  CORE_ADDR addr;
Jan Kratochvil 72aed9d
 	  struct value *addrval, *tem;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-	  if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT)
Jan Kratochvil 72aed9d
+	  if ((kind & SUBARRAY_HIGH_BOUND) != SUBARRAY_HIGH_BOUND)
Jan Kratochvil 72aed9d
 	    high = high_bound;
Jan Kratochvil 72aed9d
 	  if (high < 0)
Jan Kratochvil 72aed9d
 	    error (_("High index less than zero"));
f637971
diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/static-arrays.exp
Jan Kratochvil 72aed9d
@@ -0,0 +1,421 @@
Jan Kratochvil 72aed9d
+# Copyright 2015 Free Software Foundation, Inc.
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil 72aed9d
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil 72aed9d
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 72aed9d
+# (at your option) any later version.
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil 72aed9d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 72aed9d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 72aed9d
+# GNU General Public License for more details.
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# You should have received a copy of the GNU General Public License
Jan Kratochvil 72aed9d
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+standard_testfile static-arrays.f90
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } {
Jan Kratochvil 72aed9d
+    return -1
Jan Kratochvil 72aed9d
+}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+if ![runto MAIN__] then {
Jan Kratochvil 72aed9d
+    perror "couldn't run to breakpoint MAIN__"
Jan Kratochvil 72aed9d
+    continue
Jan Kratochvil 72aed9d
+}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_breakpoint [gdb_get_line_number "BP1"]
Jan Kratochvil 72aed9d
+gdb_continue_to_breakpoint "BP1" ".*BP1.*"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Tests subarrays of one dimensional arrays with subrange variations
Jan Kratochvil 72aed9d
+gdb_test "print ar1" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \
Jan Kratochvil 72aed9d
+		"print ar1."
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(4:7\)" "\\$\[0-9\]+ = \\(4, 5, 6, 7\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(4:7\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(8:\)" "\\$\[0-9\]+ = \\(8, 9\\).*" \
Jan Kratochvil 72aed9d
+		"print ar1\(8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(:3\)" "\\$\[0-9\]+ = \\(1, 2, 3\\).*" \
Jan Kratochvil 72aed9d
+		"print ar1\(:3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(:\)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(:\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Check assignment
Jan Kratochvil 72aed9d
+gdb_test_no_output "set \$my_ary = ar1\(3:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print \$my_ary" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \
Jan Kratochvil 72aed9d
+		"Assignment of subarray to variable"
Jan Kratochvil 72aed9d
+gdb_test_no_output "set ar1\(5\) = 42"
Jan Kratochvil 72aed9d
+		gdb_test "print ar1\(3:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(3, 4, 42, 6, 7, 8\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(3:8\) after assignment"
Jan Kratochvil 72aed9d
+gdb_test "print \$my_ary" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \
Jan Kratochvil 72aed9d
+		"Assignment of subarray to variable after original array changed"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Test for subarrays of one dimensional arrays with literals
Jan Kratochvil 72aed9d
+		gdb_test "print ar1\(3\)" "\\$\[0-9\]+ = 3" \
Jan Kratochvil 72aed9d
+		"print ar1\(3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Tests for subranges of 2 dimensional arrays with subrange variations
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(2:3, 3:4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 23, 33\\) \\( 24, 34\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(2:3, 3:4\)."
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:9,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:9,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:9,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:9,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:,8:9\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:,8:9\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(:2,2:3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 12, 22\\) \\( 13, 23\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(:2,2:3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(:2,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 18, 28\\) \\( 19, 29\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(:2,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(:2,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 11, 21\\) \\( 12, 22\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(:2,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Test subranges of 2 dimensional arrays with literals and subrange variations
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(7, 3:6\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(73, 74, 75, 76\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(7, 3:6\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(7,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(78, 79\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(7,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(7,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(71, 72\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(7,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(7:8,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(74, 84\\)" \
Jan Kratochvil 72aed9d
+		"print ar2(7:8,4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(84, 94\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:,4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(:2,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(14, 24\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(:2,4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(3,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = 34" \
Jan Kratochvil 72aed9d
+		"print ar2\(3,4\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Test subarrays of 3 dimensional arrays with literals and subrange variations
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:4,3:4,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 237, 337, 437\\) \\( 247, 347, 447\\)\
Jan Kratochvil 72aed9d
+		 \\) \\( \\( 238, 338, 438\\) \\( 248, 348, 448\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:4,3:4,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,4:5,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 248, 348\\) \\( 258, 358\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 249, 349\\) \\( 259, 359\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,4:5,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,4:5,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 241, 341\\) \\( 251, 351\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 242, 342\\) \\( 252, 352\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,4:5,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,8:,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 287, 387\\) \\( 297, 397\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 288, 388\\) \\( 298, 398\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,8:,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,8:,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 288, 388\\) \\( 298, 398\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 289, 389\\) \\( 299, 399\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,8:,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,8:,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 281, 381\\) \\( 291, 391\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 282, 382\\) \\( 292, 392\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,8:,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,:2,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 217, 317\\) \\( 227, 327\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 218, 318\\) \\( 228, 328\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,:2,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,:2,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 218, 318\\) \\( 228, 328\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 219, 319\\) \\( 229, 329\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,:2,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,:2,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 211, 311\\) \\( 221, 321\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 212, 312\\) \\( 222, 322\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,:2,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,3:4,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 837, 937\\) \\( 847, 947\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 838, 938\\) \\( 848, 948\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,3:4,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,4:5,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 848, 948\\) \\( 858, 958\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 849, 949\\) \\( 859, 959\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,4:5,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,4:5,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 841, 941\\) \\( 851, 951\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 842, 942\\) \\( 852, 952\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,4:5,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,8:,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 887, 987\\) \\( 897, 997\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 888, 988\\) \\( 898, 998\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,8:,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,8:,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 888, 988\\) \\( 898, 998\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 889, 989\\) \\( 899, 999\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,8:,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,8:,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 881, 981\\) \\( 891, 991\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 882, 982\\) \\( 892, 992\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,8:,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,:2,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 817, 917\\) \\( 827, 927\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 818, 918\\) \\( 828, 928\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,:2,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,:2,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 818, 918\\) \\( 828, 928\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 819, 919\\) \\( 829, 929\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,:2,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,:2,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 811, 911\\) \\( 821, 921\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 812, 912\\) \\( 822, 922\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,:2,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,3:4,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 137, 237\\) \\( 147, 247\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 138, 238\\) \\( 148, 248\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3 \(:2,3:4,7:8\)."
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,3:4,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 138, 238\\) \\( 148, 248\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 139, 239\\) \\( 149, 249\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,3:4,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,3:4,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 131, 231\\) \\( 141, 241\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 132, 232\\) \\( 142, 242\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,3:4,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,8:,7:8\)" "\\$\[0-9\]+ = \\(\\( \\( 187, 287\\) \\(\
Jan Kratochvil 72aed9d
+		 197, 297\\) \\) \\( \\( 188, 288\\) \\( 198, 298\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,8:,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,8:,8:\)" "\\$\[0-9\]+ = \\(\\( \\( 188, 288\\) \\( 198,\
Jan Kratochvil 72aed9d
+		 298\\) \\) \\( \\( 189, 289\\) \\( 199, 299\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,8:,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,8:,:2\)" "\\$\[0-9\]+ = \\(\\( \\( 181, 281\\) \\( 191,\
Jan Kratochvil 72aed9d
+		 291\\) \\) \\( \\( 182, 282\\) \\( 192, 292\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,8:,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,:2,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 117, 217\\) \\( 127, 227\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 118, 218\\) \\( 128, 228\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,:2,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,:2,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 118, 218\\) \\( 128, 228\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 119, 219\\) \\( 129, 229\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,:2,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,:2,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 112, 212\\) \\( 122, 222\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,:2,:2\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+#Tests for subarrays of 3 dimensional arrays with literals and subranges
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,3:4,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 337, 347\\) \\( 338, 348\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,3:4,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4:5,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 348, 358\\) \\( 349, 359\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,4:5,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4:5,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 341, 351\\) \\( 342, 352\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,4:5,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4:5,3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(343, 353\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,4:5,3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,8:,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 287, 297\\) \\( 288, 298\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,8:,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,8:,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 288, 298\\) \\( 289, 299\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,8:,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,8:,:2\)"\
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 281, 291\\) \\( 282, 292\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,8:,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,8:,3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(283, 293\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,8:,3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,:2,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 217, 227\\) \\( 218, 228\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,:2,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,:2,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 218, 228\\) \\( 219, 229\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,:2,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,:2,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 211, 221\\) \\( 212, 222\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,:2,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2,:2,3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(213, 223\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2,:2,3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(347, 348\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,4,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(348, 349\\)" \
Jan Kratochvil 72aed9d
+i		"print ar3\(3,4,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3,4,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(341, 342\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3,4,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(5,6,7\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = 567" \
Jan Kratochvil 72aed9d
+		"print ar3\(5,6,7\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3:4,6,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 367, 467\\) \\( 368, 468\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3:4,6,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3:4,6,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 368, 468\\) \\( 369, 469\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3:4,6,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3:4,6,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 361, 461\\) \\( 362, 462\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3:4,6,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3:4,6,5\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(365, 465\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(3:4,6,5\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,6,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 867, 967\\) \\( 868, 968\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,6,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,6,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 868, 968\\) \\( 869, 969\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,6,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,6,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 861, 961\\) \\( 862, 962\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,6,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,6,5\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(865, 965\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(8:,6,5\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,6,7:8\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 167, 267\\) \\( 168, 268\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,6,7:8\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,6,8:\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 168, 268\\) \\( 169, 269\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,6,8:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,6,:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 161, 261\\) \\( 162, 262\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,6,:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,6,5\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(165, 265\\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(:2,6,5\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(3:4,5:6,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 354, 454\\) \\( 364, 464\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(3:4,5:6,4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(8:,5:6,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 854, 954\\) \\( 864, 964\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:,5:6,4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(:2,5:6,4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 154, 254\\) \\( 164, 264\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(:2,5:6,4\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Stride > 1
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(2:6:2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(2, 4, 6\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(2:6:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(2:6:2,3:4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 23, 43, 63\\) \\( 24, 44, 64\\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(2:6:2,3:4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(2:6:2,3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(23, 43, 63\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(2:6:2,3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:6:2,3:5:2,4:7:3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 234, 434, 634\\) \\( 254, 454, 654\\)\
Jan Kratochvil 72aed9d
+		 \\) \\( \\( 237, 437, 637\\) \\( 257, 457, 657\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:6:2,3:5:2,4:7:3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:6:2,5,4:7:3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 254, 454, 654\\) \\( 257, 457, 657\\)\
Jan Kratochvil 72aed9d
+		 \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:6:2,5,4:7:3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Stride < 0
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(8:2:-2\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(8, 6, 4, 2\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(8:2:-2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(8:2:-2,3:4\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 83, 63, 43, 23\\) \\( 84, 64, 44, 24\\)\
Jan Kratochvil 72aed9d
+		 \\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(8:2:-2,3:4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar2\(2:6:2,3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(23, 43, 63\\)" \
Jan Kratochvil 72aed9d
+		"print ar2\(2:6:2,3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:3,7:3:-4,4:7:3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 274, 374\\) \\( 234, 334\\) \\) \\(\
Jan Kratochvil 72aed9d
+		 \\( 277, 377\\) \\( 237, 337\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:3,7:3:-4,4:7:3\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar3\(2:6:2,5,7:4:-3\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( 257, 457, 657\\) \\( 254, 454, 654\\)\
Jan Kratochvil 72aed9d
+		 \\)" \
Jan Kratochvil 72aed9d
+		"print ar3\(2:6:2,5,7:4:-3\)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Tests with negative and mixed indices
Jan Kratochvil 72aed9d
+gdb_test "p ar4\(2:4, -2:1, -15:-14\)" \
Jan Kratochvil 72aed9d
+		"\\$\[0-9\]+ = \\(\\( \\( 261, 361, 461\\) \\( 271, 371, 471\\)\
Jan Kratochvil 72aed9d
+		 \\( 281, 381, 481\\) \\( 291, 391, 491\\) \\) \\( \\( 262,\
Jan Kratochvil 72aed9d
+		 362, 462\\) \\( 272, 372, 472\\) \\( 282, 382, 482\\) \\( 292,\
Jan Kratochvil 72aed9d
+		 392, 492\\) \\) \\)" \
Jan Kratochvil 72aed9d
+		"print ar4(2:4, -2:1, -15:-14)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "p ar4\(7,-6:2:3,-7\)" \
Jan Kratochvil 72aed9d
+                "\\$\[0-9\]+ = \\(729, 759, 789\\)" \
Jan Kratochvil 72aed9d
+                "print ar4(7,-6:2:3,-7)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "p ar4\(9:2:-2, -6:2:3, -6:-15:-3\)" \
Jan Kratochvil 72aed9d
+                "\\$\[0-9\]+ = \\(\\( \\( 930, 730, 530, 330\\) \\( 960, 760,\
Jan Kratochvil 72aed9d
+		 560, 360\\) \\( 990, 790, 590, 390\\) \\) \\( \\( 927, 727,\
Jan Kratochvil 72aed9d
+		 527, 327\\) \\( 957, 757, 557, 357\\) \\( 987, 787, 587,\
Jan Kratochvil 72aed9d
+		 387\\) \\) \\( \\( 924, 724, 524, 324\\) \\( 954, 754, 554,\
Jan Kratochvil 72aed9d
+		 354\\) \\( 984, 784, 584, 384\\) \\) \\( \\( 921, 721, 521,\
Jan Kratochvil 72aed9d
+		 321\\) \\( 951, 751, 551, 351\\) \\( 981, 781, 581, 381\\) \\)\
Jan Kratochvil 72aed9d
+		 \\)" \
Jan Kratochvil 72aed9d
+                "print ar4(9:2:-2, -6:2:3, -6:-15:-3)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_test "p ar4\(:,:,:\)" \
Jan Kratochvil 72aed9d
+                "\\$\[0-9\]+ = \\(\\( \\( 111, 211, 311, 411, 511, 611, 711,\
Jan Kratochvil 72aed9d
+		 811, .*" \
Jan Kratochvil 72aed9d
+                "print ar4(:,:,:)"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# Provoke error messages for bad user input
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(0:4\)" \
Jan Kratochvil 72aed9d
+		"provided bound\\(s\\) outside array bound\\(s\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(0:4\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(8:12\)" \
Jan Kratochvil 72aed9d
+		"provided bound\\(s\\) outside array bound\\(s\\)" \
Jan Kratochvil 72aed9d
+		"print ar1\(8:12\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(8:2:\)" \
Jan Kratochvil 72aed9d
+		"A syntax error in expression, near `\\)'." \
Jan Kratochvil 72aed9d
+		"print ar1\(8:2:\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(8:2:2\)" \
Jan Kratochvil 72aed9d
+		"Wrong value provided for stride and boundaries" \
Jan Kratochvil 72aed9d
+		"print ar1\(8:2:2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(2:8:-2\)" \
Jan Kratochvil 72aed9d
+		"Wrong value provided for stride and boundaries" \
Jan Kratochvil 72aed9d
+		"print ar1\(2:8:-2\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(2:7:0\)" \
Jan Kratochvil 72aed9d
+		"Stride must not be 0" \
Jan Kratochvil 72aed9d
+		"print ar1\(2:7:0\)"
Jan Kratochvil 72aed9d
+gdb_test "print ar1\(3:7\) = 42" \
Jan Kratochvil 72aed9d
+		"Invalid cast." \
Jan Kratochvil 72aed9d
+		"Assignment of value to subarray"
f637971
diff --git a/gdb/testsuite/gdb.fortran/static-arrays.f90 b/gdb/testsuite/gdb.fortran/static-arrays.f90
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/static-arrays.f90
Jan Kratochvil 72aed9d
@@ -0,0 +1,55 @@
Jan Kratochvil 72aed9d
+! Copyright 2015 Free Software Foundation, Inc.
Jan Kratochvil 72aed9d
+!
Jan Kratochvil 72aed9d
+! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
Jan Kratochvil 72aed9d
+!
Jan Kratochvil 72aed9d
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil 72aed9d
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil 72aed9d
+! the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 72aed9d
+! (at your option) any later version.
Jan Kratochvil 72aed9d
+!
Jan Kratochvil 72aed9d
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil 72aed9d
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 72aed9d
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 72aed9d
+! GNU General Public License for more details.
Jan Kratochvil 72aed9d
+!
Jan Kratochvil 72aed9d
+! You should have received a copy of the GNU General Public License
Jan Kratochvil 72aed9d
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+subroutine sub
Jan Kratochvil 72aed9d
+  integer, dimension(9) :: ar1
Jan Kratochvil 72aed9d
+  integer, dimension(9,9) :: ar2
Jan Kratochvil 72aed9d
+  integer, dimension(9,9,9) :: ar3
Jan Kratochvil 72aed9d
+  integer, dimension(10,-7:3, -15:-5) :: ar4
Jan Kratochvil 72aed9d
+  integer :: i,j,k
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  ar1 = 1
Jan Kratochvil 72aed9d
+  ar2 = 1
Jan Kratochvil 72aed9d
+  ar3 = 1
Jan Kratochvil 72aed9d
+  ar4 = 4
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...)))
Jan Kratochvil 72aed9d
+  do i = 1, 9, 1
Jan Kratochvil 72aed9d
+    ar1(i) = i
Jan Kratochvil 72aed9d
+    do j = 1, 9, 1
Jan Kratochvil 72aed9d
+      ar2(i,j) = i*10 + j
Jan Kratochvil 72aed9d
+      do k = 1, 9, 1
Jan Kratochvil 72aed9d
+        ar3(i,j,k) = i*100 + j*10 + k
Jan Kratochvil 72aed9d
+      end do
Jan Kratochvil 72aed9d
+    end do
Jan Kratochvil 72aed9d
+  end do
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  do i = 1, 10, 1
Jan Kratochvil 72aed9d
+    do j = -7, 3, 1
Jan Kratochvil 72aed9d
+      do k = -15, -5, 1
Jan Kratochvil 72aed9d
+        ar4(i,j,k) = i*100 + (j+8)*10 + (k+16)
Jan Kratochvil 72aed9d
+      end do
Jan Kratochvil 72aed9d
+    end do
Jan Kratochvil 72aed9d
+  end do
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  ar1(1) = 11  !BP1
Jan Kratochvil 72aed9d
+  return
Jan Kratochvil 72aed9d
+end
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+program testprog
Jan Kratochvil 72aed9d
+  call sub
Jan Kratochvil 72aed9d
+end
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
f637971
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
06f4849
@@ -32,7 +32,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
06f4849
 gdb_test "print sizeof(vla1(3,2,1))" \
06f4849
     "no such vector element \\(vector not allocated\\)" \
06f4849
     "print sizeof non-allocated indexed vla1"
292cb41
-gdb_test "print sizeof(vla1(3:4,2,1))" "array not allocated" \
06f4849
+gdb_test "print sizeof(vla1(3:4,2,1))" \
06f4849
+    "provided bound\\(s\\) outside array bound\\(s\\)" \
06f4849
     "print sizeof non-allocated sliced vla1"
06f4849
 
06f4849
 # Try to access value in allocated VLA
06f4849
@@ -41,7 +42,7 @@ gdb_continue_to_breakpoint "vla1-allocated"
06f4849
 gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
06f4849
 gdb_test "print sizeof(vla1(3,2,1))" "4" \
06f4849
     "print sizeof element from allocated vla1"
06f4849
-gdb_test "print sizeof(vla1(3:4,2,1))" "800" \
06f4849
+gdb_test "print sizeof(vla1(3:4,2,1))" "8" \
06f4849
     "print sizeof sliced vla1"
06f4849
 
06f4849
 # Try to access values in undefined pointer to VLA (dangling)
06f4849
@@ -49,7 +50,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
06f4849
 gdb_test "print sizeof(pvla(3,2,1))" \
06f4849
     "no such vector element \\(vector not associated\\)" \
06f4849
     "print sizeof non-associated indexed pvla"
292cb41
-gdb_test "print sizeof(pvla(3:4,2,1))" "array not associated" \
06f4849
+gdb_test "print sizeof(pvla(3:4,2,1))" \
06f4849
+    "provided bound\\(s\\) outside array bound\\(s\\)" \
06f4849
     "print sizeof non-associated sliced pvla"
06f4849
 
06f4849
 # Try to access values in pointer to VLA and compare them
f7760f8
@@ -58,7 +60,8 @@ gdb_continue_to_breakpoint "pvla-associated"
Jan Kratochvil d258670
 gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
06f4849
 gdb_test "print sizeof(pvla(3,2,1))" "4" \
06f4849
     "print sizeof element from associated pvla"
06f4849
-gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla"
Jan Kratochvil d258670
+
f7760f8
+gdb_test "print sizeof(pvla(3:4,2,1))" "8" "print sizeof sliced pvla"
f7760f8
 
f7760f8
 gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"]
f7760f8
 gdb_continue_to_breakpoint "vla1-neg-bounds-v1"
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp
a5d2c85
@@ -0,0 +1,47 @@
Jan Kratochvil 72aed9d
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil 72aed9d
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil 72aed9d
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 72aed9d
+# (at your option) any later version.
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil 72aed9d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 72aed9d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 72aed9d
+# GNU General Public License for more details.
Jan Kratochvil 72aed9d
+#
Jan Kratochvil 72aed9d
+# You should have received a copy of the GNU General Public License
Jan Kratochvil 72aed9d
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+standard_testfile ".f90"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil 72aed9d
+    {debug f90 quiet}] } {
Jan Kratochvil 72aed9d
+    return -1
Jan Kratochvil 72aed9d
+}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+if ![runto MAIN__] then {
Jan Kratochvil 72aed9d
+    perror "couldn't run to breakpoint MAIN__"
Jan Kratochvil 72aed9d
+    continue
Jan Kratochvil 72aed9d
+}
Jan Kratochvil 72aed9d
+
a5d2c85
+gdb_test_no_output "set max-value-size unlimited" \
a5d2c85
+    "set max-value-size to unlimited"
a5d2c85
+
Jan Kratochvil 72aed9d
+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
Jan Kratochvil 72aed9d
+gdb_continue_to_breakpoint "re-reverse-elements"
Jan Kratochvil 72aed9d
+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
Jan Kratochvil 72aed9d
+  "print re-reverse-elements"
Jan Kratochvil 72aed9d
+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
Jan Kratochvil 72aed9d
+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_breakpoint [gdb_get_line_number "odd-elements"]
Jan Kratochvil 72aed9d
+gdb_continue_to_breakpoint "odd-elements"
Jan Kratochvil 72aed9d
+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
Jan Kratochvil 72aed9d
+gdb_test "print pvla(1)" " = 1" "print first odd-element"
Jan Kratochvil 72aed9d
+gdb_test "print pvla(5)" " = 9" "print last odd-element"
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+gdb_breakpoint [gdb_get_line_number "single-element"]
Jan Kratochvil 72aed9d
+gdb_continue_to_breakpoint "single-element"
Jan Kratochvil 72aed9d
+gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
Jan Kratochvil 72aed9d
+gdb_test "print pvla(1)" " = 5" "print one single-element"
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90
Jan Kratochvil 72aed9d
@@ -0,0 +1,29 @@
Jan Kratochvil 72aed9d
+! Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil 72aed9d
+!
Jan Kratochvil 72aed9d
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil 72aed9d
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil 72aed9d
+! the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 72aed9d
+! (at your option) any later version.
Jan Kratochvil d258670
+!
Jan Kratochvil 72aed9d
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil 72aed9d
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 72aed9d
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 72aed9d
+! GNU General Public License for more details.
Jan Kratochvil d258670
+!
Jan Kratochvil 72aed9d
+! You should have received a copy of the GNU General Public License
Jan Kratochvil 72aed9d
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+program vla_stride
Jan Kratochvil 72aed9d
+  integer, target, allocatable :: vla (:)
Jan Kratochvil 72aed9d
+  integer, pointer :: pvla (:)
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  allocate(vla(10))
Jan Kratochvil 72aed9d
+  vla = (/ (I, I = 1,10) /)
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  pvla => vla(10:1:-1)
Jan Kratochvil 72aed9d
+  pvla => pvla(10:1:-1)
Jan Kratochvil 72aed9d
+  pvla => vla(1:10:2)   ! re-reverse-elements
Jan Kratochvil 72aed9d
+  pvla => vla(5:4:-2)   ! odd-elements
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  pvla => null()        ! single-element
Jan Kratochvil 72aed9d
+end program vla_stride
f637971
diff --git a/gdb/valops.c b/gdb/valops.c
f637971
--- a/gdb/valops.c
f637971
+++ b/gdb/valops.c
a5d2c85
@@ -3797,13 +3797,42 @@ value_of_this_silent (const struct language_defn *lang)
f637971
 
Jan Kratochvil 72aed9d
 struct value *
Jan Kratochvil 72aed9d
 value_slice (struct value *array, int lowbound, int length)
f637971
+{
Jan Kratochvil 72aed9d
+  /* Pass unaltered arguments to VALUE_SLICE_1, plus a default stride
Jan Kratochvil 72aed9d
+     value of '1', which returns every element between LOWBOUND and
Jan Kratochvil 72aed9d
+     (LOWBOUND + LENGTH).  We also provide a default CALL_COUNT of '1'
Jan Kratochvil 72aed9d
+     as we are only considering the highest dimension, or we are
Jan Kratochvil 72aed9d
+     working on a one dimensional array.  So we call VALUE_SLICE_1
Jan Kratochvil 72aed9d
+     exactly once.  */
Jan Kratochvil 72aed9d
+  return value_slice_1 (array, lowbound, length, 1, 1);
Jan Kratochvil 72aed9d
+}
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+/* VALUE_SLICE_1 is called for each array dimension to calculate the number
Jan Kratochvil 72aed9d
+   of elements as defined by the subscript expression.
Jan Kratochvil 72aed9d
+   CALL_COUNT is used to determine if we are calling the function once, e.g.
Jan Kratochvil 72aed9d
+   we are working on the current dimension of ARRAY, or if we are calling
Jan Kratochvil 72aed9d
+   the function repeatedly.  In the later case we need to take elements
Jan Kratochvil 72aed9d
+   from the TARGET_TYPE of ARRAY.
Jan Kratochvil 72aed9d
+   With a CALL_COUNT greater than 1 we calculate the offsets for every element
Jan Kratochvil 72aed9d
+   that should be in the result array.  Then we fetch the contents and then
Jan Kratochvil 72aed9d
+   copy them into the result array.  The result array will have one dimension
Jan Kratochvil 72aed9d
+   less than the input array, so later on we need to recreate the indices and
Jan Kratochvil 72aed9d
+   ranges in the calling function.  */
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+struct value *
Jan Kratochvil 72aed9d
+value_slice_1 (struct value *array, int lowbound, int length,
Jan Kratochvil 72aed9d
+	       int stride_length, int call_count)
f637971
 {
Jan Kratochvil 72aed9d
   struct type *slice_range_type, *slice_type, *range_type;
Jan Kratochvil 72aed9d
-  LONGEST lowerbound, upperbound;
Jan Kratochvil 72aed9d
-  struct value *slice;
Jan Kratochvil 72aed9d
-  struct type *array_type;
Jan Kratochvil 72aed9d
+  struct type *array_type = check_typedef (value_type (array));
Jan Kratochvil 72aed9d
+  struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+  unsigned int elt_size, elt_offs;
Jan Kratochvil 72aed9d
+  LONGEST ary_high_bound, ary_low_bound;
Jan Kratochvil 72aed9d
+  struct value *v;
Jan Kratochvil 72aed9d
+  int slice_range_size, i = 0, row_count = 1, elem_count = 1;
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-  array_type = check_typedef (value_type (array));
Jan Kratochvil 72aed9d
+  /* Check for legacy code if we are actually dealing with an array or
Jan Kratochvil 72aed9d
+     string.  */
Jan Kratochvil 72aed9d
   if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY
Jan Kratochvil 72aed9d
       && TYPE_CODE (array_type) != TYPE_CODE_STRING)
Jan Kratochvil 72aed9d
     error (_("cannot take slice of non-array"));
a5d2c85
@@ -3813,45 +3842,155 @@ value_slice (struct value *array, int lowbound, int length)
292cb41
   if (type_not_associated (array_type))
292cb41
     error (_("array not associated"));
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-  range_type = TYPE_INDEX_TYPE (array_type);
Jan Kratochvil 72aed9d
-  if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
Jan Kratochvil 72aed9d
-    error (_("slice from bad array or bitstring"));
Jan Kratochvil 72aed9d
+  ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (array_type));
Jan Kratochvil 72aed9d
+  ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (array_type));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* When we are working on a multi-dimensional array, we need to get the
Jan Kratochvil 72aed9d
+     attributes of the underlying type.  */
Jan Kratochvil 72aed9d
+  if (call_count > 1)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (elt_type));
Jan Kratochvil 72aed9d
+      ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (elt_type));
Jan Kratochvil 72aed9d
+      elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
Jan Kratochvil 72aed9d
+      row_count = TYPE_LENGTH (array_type)
Jan Kratochvil 72aed9d
+		    / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* With a stride of '1', the number of elements per result row is equal to
Jan Kratochvil 72aed9d
+     the LENGTH of the subarray.  With non-default stride values, we skip
Jan Kratochvil 72aed9d
+     elements, but have to add the start element to the total number of
Jan Kratochvil 72aed9d
+     elements per row.  */
Jan Kratochvil 72aed9d
+  if (stride_length == 1)
Jan Kratochvil 72aed9d
+    elem_count = length;
Jan Kratochvil 72aed9d
+  else
Jan Kratochvil 72aed9d
+    elem_count = ((length - 1) / stride_length) + 1;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  elt_size = TYPE_LENGTH (elt_type);
Jan Kratochvil 72aed9d
+  elt_offs = lowbound - ary_low_bound;
f637971
 
f637971
-  if (lowbound < lowerbound || length < 0
f637971
-      || lowbound + length - 1 > upperbound)
f637971
-    error (_("slice out of range"));
Jan Kratochvil 72aed9d
+  elt_offs *= elt_size;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* Check for valid user input.  In case of Fortran this was already done
Jan Kratochvil 72aed9d
+     in the calling function.  */
Jan Kratochvil 72aed9d
+  if (call_count == 1
Jan Kratochvil 72aed9d
+	&& (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
Jan Kratochvil 72aed9d
+	      && elt_offs >= TYPE_LENGTH (array_type)))
Jan Kratochvil 72aed9d
+    error (_("no such vector element"));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+  /* CALL_COUNT is 1 when we are dealing either with the highest dimension
Jan Kratochvil 72aed9d
+     of the array, or a one dimensional array.  Set RANGE_TYPE accordingly.
Jan Kratochvil 72aed9d
+     In both cases we calculate how many rows/elements will be in the output
Jan Kratochvil 72aed9d
+     array by setting slice_range_size.  */
Jan Kratochvil 72aed9d
+  if (call_count == 1)
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      range_type = TYPE_INDEX_TYPE (array_type);
Jan Kratochvil 72aed9d
+      slice_range_size = ary_low_bound + elem_count - 1;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+      /* Check if the array bounds are valid.  */
Jan Kratochvil 72aed9d
+      if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0)
Jan Kratochvil 72aed9d
+	error (_("slice from bad array or bitstring"));
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
+  /* When CALL_COUNT is greater than 1, we are dealing with an array of arrays.
Jan Kratochvil 72aed9d
+     So we need to get the type below the current one and set the RANGE_TYPE
Jan Kratochvil 72aed9d
+     accordingly.  */
Jan Kratochvil 72aed9d
+  else
Jan Kratochvil 72aed9d
+    {
Jan Kratochvil 72aed9d
+      range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+      slice_range_size = ary_low_bound + (row_count * elem_count) - 1;
Jan Kratochvil 72aed9d
+      ary_low_bound = TYPE_LOW_BOUND (range_type);
Jan Kratochvil 72aed9d
+    }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
   /* FIXME-type-allocation: need a way to free this type when we are
Jan Kratochvil 72aed9d
-     done with it.  */
292cb41
-  slice_range_type = create_static_range_type (NULL,
Jan Kratochvil 72aed9d
-					       TYPE_TARGET_TYPE (range_type),
Jan Kratochvil 72aed9d
-					       lowbound,
Jan Kratochvil 72aed9d
-					       lowbound + length - 1);
Jan Kratochvil 72aed9d
+      done with it.  */
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
+  slice_range_type = create_static_range_type (NULL, TYPE_TARGET_TYPE (range_type),
Jan Kratochvil 72aed9d
+					       ary_low_bound, slice_range_size);
Jan Kratochvil 72aed9d
   {
Jan Kratochvil 72aed9d
-    struct type *element_type = TYPE_TARGET_TYPE (array_type);
Jan Kratochvil 72aed9d
-    LONGEST offset
Jan Kratochvil 72aed9d
-      = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
Jan Kratochvil 72aed9d
+    struct type *element_type;
Jan Kratochvil 0fffd6c
+
Jan Kratochvil 72aed9d
+    /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy
Jan Kratochvil 72aed9d
+       code for subarrays.  */
Jan Kratochvil 72aed9d
+    if (call_count == 1 && stride_length == 1)
Jan Kratochvil 72aed9d
+      {
Jan Kratochvil 72aed9d
+	element_type = TYPE_TARGET_TYPE (array_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	slice_type = create_array_type (NULL, element_type, slice_range_type);
f637971
 
292cb41
-    slice_type = create_array_type (NULL,
f637971
-				    element_type,
f637971
-				    slice_range_type);
f637971
-    TYPE_CODE (slice_type) = TYPE_CODE (array_type);
Jan Kratochvil 72aed9d
+	TYPE_CODE (slice_type) = TYPE_CODE (array_type);
f637971
 
f637971
-    if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
f637971
-      slice = allocate_value_lazy (slice_type);
Jan Kratochvil 72aed9d
+	if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
Jan Kratochvil 72aed9d
+	  v = allocate_value_lazy (slice_type);
Jan Kratochvil 72aed9d
+	else
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+	    v = allocate_value (slice_type);
Jan Kratochvil 72aed9d
+	    value_contents_copy (v,
Jan Kratochvil 72aed9d
+				 value_embedded_offset (v),
Jan Kratochvil 72aed9d
+				 array,
Jan Kratochvil 72aed9d
+				 value_embedded_offset (array) + elt_offs,
Jan Kratochvil 72aed9d
+				 elt_size * longest_to_int (length));
Jan Kratochvil 72aed9d
+	  }
f637971
+
Jan Kratochvil 72aed9d
+      }
Jan Kratochvil 72aed9d
+    /* With a CALL_COUNT or STRIDE_LENGTH are greater than 1 we are working
Jan Kratochvil 72aed9d
+       on a range of ranges.  So we copy the relevant elements into the
Jan Kratochvil 72aed9d
+       new array we return.  */
Jan Kratochvil 72aed9d
     else
Jan Kratochvil 72aed9d
       {
Jan Kratochvil 72aed9d
-	slice = allocate_value (slice_type);
Jan Kratochvil 72aed9d
-	value_contents_copy (slice, 0, array, offset,
Jan Kratochvil 72aed9d
-			     type_length_units (slice_type));
Jan Kratochvil 72aed9d
+	int j, offs_store = elt_offs;
Jan Kratochvil 72aed9d
+	LONGEST dst_offset = 0;
Jan Kratochvil 72aed9d
+	LONGEST src_row_length = TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	if (call_count == 1)
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+	    /* When CALL_COUNT is equal to 1 we are working on the current range
Jan Kratochvil 72aed9d
+	       and use these elements directly.  */
Jan Kratochvil 72aed9d
+	    element_type = TYPE_TARGET_TYPE (array_type);
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
+	else
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+	    /* Working on an array of arrays, the type of the elements is the type
Jan Kratochvil 72aed9d
+	       of the subarrays' type.  */
Jan Kratochvil 72aed9d
+	    element_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	slice_type = create_array_type (NULL, element_type, slice_range_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	 /* If we have a one dimensional array, we copy its TYPE_CODE.  For a
Jan Kratochvil 72aed9d
+	    multi dimensional array we copy the embedded type's TYPE_CODE.  */
Jan Kratochvil 72aed9d
+	if (call_count == 1)
Jan Kratochvil 72aed9d
+	  TYPE_CODE (slice_type) = TYPE_CODE (array_type);
Jan Kratochvil 72aed9d
+	else
Jan Kratochvil 72aed9d
+	  TYPE_CODE (slice_type) = TYPE_CODE (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	v = allocate_value (slice_type);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	/* Iterate through the rows of the outer array and set the new offset
Jan Kratochvil 72aed9d
+	   for each row.  */
Jan Kratochvil 72aed9d
+	for (i = 0; i < row_count; i++)
Jan Kratochvil 72aed9d
+	  {
Jan Kratochvil 72aed9d
+	    elt_offs = offs_store + i * src_row_length;
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
+	    /* Iterate through the elements in each row to copy only those.  */
Jan Kratochvil 72aed9d
+	    for (j = 1; j <= elem_count; j++)
Jan Kratochvil 72aed9d
+	      {
Jan Kratochvil 72aed9d
+		/* Fetches the contents of ARRAY and copies them into V.  */
Jan Kratochvil 72aed9d
+		value_contents_copy (v, dst_offset, array, elt_offs, elt_size);
Jan Kratochvil 72aed9d
+		elt_offs += elt_size * stride_length;
Jan Kratochvil 72aed9d
+		dst_offset += elt_size;
Jan Kratochvil 72aed9d
+	      }
Jan Kratochvil 72aed9d
+	  }
Jan Kratochvil 72aed9d
       }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-    set_value_component_location (slice, array);
Jan Kratochvil 72aed9d
-    set_value_offset (slice, value_offset (array) + offset);
Jan Kratochvil 72aed9d
+    set_value_component_location (v, array);
Jan Kratochvil 0fffd6c
+    if (VALUE_LVAL (v) == lval_register)
Jan Kratochvil 0fffd6c
+      {
Jan Kratochvil 0fffd6c
+	VALUE_REGNUM (v) = VALUE_REGNUM (array);
Jan Kratochvil 0fffd6c
+	VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array);
Jan Kratochvil 0fffd6c
+      }
Jan Kratochvil 72aed9d
+    set_value_offset (v, value_offset (array) + elt_offs);
Jan Kratochvil 72aed9d
   }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
-  return slice;
Jan Kratochvil 72aed9d
+  return v;
Jan Kratochvil 72aed9d
 }
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 /* Create a value for a FORTRAN complex number.  Currently most of the
f637971
diff --git a/gdb/value.h b/gdb/value.h
f637971
--- a/gdb/value.h
f637971
+++ b/gdb/value.h
0a2f2a5
@@ -1145,6 +1145,8 @@ extern struct value *varying_to_slice (struct value *);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
 extern struct value *value_slice (struct value *, int, int);
Jan Kratochvil 72aed9d
 
Jan Kratochvil 72aed9d
+extern struct value *value_slice_1 (struct value *, int, int, int, int);
Jan Kratochvil 72aed9d
+
Jan Kratochvil 72aed9d
 extern struct value *value_literal_complex (struct value *, struct value *,
Jan Kratochvil 72aed9d
 					    struct type *);
Jan Kratochvil 72aed9d