diff --git a/gdb/eval.c b/gdb/eval.c
--- a/gdb/eval.c
+++ b/gdb/eval.c
-@@ -372,29 +372,324 @@ init_array_element (struct value *array, struct value *element,
+@@ -371,29 +371,323 @@ init_array_element (struct value *array, struct value *element,
return index;
}
{
- int pc = (*pos) + 1;
- LONGEST low_bound, high_bound;
-- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
+- struct type *range = check_typedef (value_type (array)->index_type ());
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
-
- *pos += 3;
-
- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-- low_bound = TYPE_LOW_BOUND (range);
+- low_bound = range->bounds ()->low.const_val ();
- else
-- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+- low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+ int i, dim_count = 0;
+ struct value *new_array = array;
+ struct type *array_type = check_typedef (value_type (new_array));
+ upper bound. */
+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND)
+ == SUBARRAY_LOW_BOUND)
-+ range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp,
++ range->low = value_as_long (evaluate_subexp (nullptr, exp,
+ pos, noside));
+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND)
+ == SUBARRAY_HIGH_BOUND)
-+ range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
++ range->high = value_as_long (evaluate_subexp (nullptr, exp,
+ pos, noside));
+
+ /* Assign the user's stride value if provided. */
+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
-+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
++ range->stride = value_as_long (evaluate_subexp (nullptr, exp,
+ pos, noside));
+
+ /* Assign the default stride value '1'. */
+ range->stride = 1;
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-- high_bound = TYPE_HIGH_BOUND (range);
+- high_bound = range->bounds ()->high.const_val ();
- else
-- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+- high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
+ /* Check the provided stride value is illegal, aka '0'. */
+ if (range->stride == 0)
+ error (_("Stride must not be 0"));
+ for (i = nargs - 1; i >= 0; i--)
+ {
+ struct subscript_store *index = &subscript_array[i];
-+ struct type *index_type = TYPE_INDEX_TYPE (array_type);
++ struct type *index_type = array_type->index_type ();
+
+ switch (index->kind)
+ {
+ /* If no lower bound was provided by the user, we take the
+ default boundary. Same for the high bound. */
+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0)
-+ range->low = TYPE_LOW_BOUND (index_type);
++ range->low = index_type->bounds ()->low.const_val ();
+
+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0)
-+ range->high = TYPE_HIGH_BOUND (index_type);
++ range->high = index_type->bounds ()->high.const_val ();
+
+ /* Both user provided low and high bound have to be inside the
+ array bounds. Throw an error if not. */
-+ if (range->low < TYPE_LOW_BOUND (index_type)
-+ || range->low > TYPE_HIGH_BOUND (index_type)
-+ || range->high < TYPE_LOW_BOUND (index_type)
-+ || range->high > TYPE_HIGH_BOUND (index_type))
++ if (range->low < index_type->bounds ()->low.const_val ()
++ || range->low > index_type->bounds ()->high.const_val ()
++ || range->high < index_type->bounds ()->low.const_val ()
++ || range->high > index_type->bounds ()->high.const_val ())
+ error (_("provided bound(s) outside array bound(s)"));
+
+ /* For a negative stride the lower boundary must be larger than the
+ for (i = nargs - 1; i >= 0; i--)
+ {
+ struct subscript_store *index = &subscript_array[i];
-+ struct type *index_type = TYPE_INDEX_TYPE (array_type);
++ struct type *index_type = array_type->index_type ();
+
+ switch (index->kind)
+ {
+ cannot do the range checks for us. So we have to make sure
+ ourselves that the user provided index is inside the
+ array bounds. Throw an error if not. */
-+ if (index->U.number < TYPE_LOW_BOUND (index_type)
-+ && index->U.number > TYPE_HIGH_BOUND (index_type))
++ if (index->U.number < index_type->bounds ()->low.const_val ()
++ && index->U.number > index_type->bounds ()->high.const_val ())
+ error (_("provided bound(s) outside array bound(s)"));
+
-+ if (index->U.number > TYPE_LOW_BOUND (index_type)
-+ && index->U.number > TYPE_HIGH_BOUND (index_type))
++ if (index->U.number > index_type->bounds ()->low.const_val ()
++ && index->U.number > index_type->bounds ()->high.const_val ())
+ error (_("provided bound(s) outside array bound(s)"));
+
+ new_array = value_slice_1 (new_array,
+ elt_type,
+ range_type);
+
-+ TYPE_CODE (interim_array_type)
-+ = TYPE_CODE (value_type (new_array));
++ interim_array_type->set_code ( value_type (new_array)->code ());
+
+ v = allocate_value (interim_array_type);
+
}
-@@ -1235,19 +1530,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
+@@ -1233,19 +1527,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
}
- enum noside noside)
-{
- for (int i = 0; i < nargs; ++i)
-- evaluate_subexp (NULL_TYPE, exp, pos, noside);
+- evaluate_subexp (nullptr, exp, pos, noside);
-}
-
- struct value *
- evaluate_subexp_standard (struct type *expect_type,
- struct expression *exp, int *pos,
-@@ -1942,33 +2224,8 @@ evaluate_subexp_standard (struct type *expect_type,
+ /* Return true if type is integral or reference to integral */
+
+ static bool
+@@ -1953,33 +2234,8 @@ evaluate_subexp_standard (struct type *expect_type,
switch (code)
{
case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
-@@ -2388,49 +2645,6 @@ evaluate_subexp_standard (struct type *expect_type,
+@@ -2400,49 +2656,6 @@ evaluate_subexp_standard (struct type *expect_type,
}
return (arg1);
- }
-
case BINOP_LOGICAL_AND:
- arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ arg1 = evaluate_subexp (nullptr, exp, pos, noside);
if (noside == EVAL_SKIP)
-@@ -3350,6 +3564,9 @@ calc_f77_array_dims (struct type *array_type)
+@@ -3360,6 +3573,9 @@ calc_f77_array_dims (struct type *array_type)
int ndimen = 1;
struct type *tmp_type;
-+ if (TYPE_CODE (array_type) == TYPE_CODE_STRING)
++ if (array_type->code () == TYPE_CODE_STRING)
+ return 1;
+
- if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
+ if ((array_type->code () != TYPE_CODE_ARRAY))
error (_("Can't get dimensions for a non-array type"));
diff --git a/gdb/expprint.c b/gdb/expprint.c
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
-@@ -580,17 +580,14 @@ print_subexp_standard (struct expression *exp, int *pos,
+@@ -576,17 +576,14 @@ print_subexp_standard (struct expression *exp, int *pos,
longest_to_int (exp->elts[pc + 1].longconst);
*pos += 2;
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered (")", stream);
return;
-@@ -1107,22 +1104,24 @@ dump_subexp_body_standard (struct expression *exp,
+@@ -1103,22 +1100,24 @@ dump_subexp_body_standard (struct expression *exp,
switch (range_type)
{
fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
break;
default:
-@@ -1130,11 +1129,9 @@ dump_subexp_body_standard (struct expression *exp,
+@@ -1126,11 +1125,9 @@ dump_subexp_body_standard (struct expression *exp,
break;
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
-@@ -936,7 +936,7 @@ create_range_type (struct type *result_type, struct type *index_type,
- TYPE_RANGE_DATA (result_type)->high = *high_bound;
- TYPE_RANGE_DATA (result_type)->bias = bias;
-
-- /* Initialize the stride to be a constant, the value will already be zero
-+ /* bias the stride to be a constant, the value will already be zero
- thanks to the use of TYPE_ZALLOC above. */
- TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST;
-
-@@ -1001,7 +1001,8 @@ create_static_range_type (struct type *result_type, struct type *index_type,
- high.kind = PROP_CONST;
- high.data.const_val = high_bound;
+@@ -1006,7 +1006,8 @@ create_static_range_type (struct type *result_type, struct type *index_type,
+ low.set_const_val (low_bound);
+ high.set_const_val (high_bound);
- result_type = create_range_type (result_type, index_type, &low, &high, 0);
+ result_type = create_range_type (result_type, index_type,
return result_type;
}
-@@ -1236,6 +1237,7 @@ create_array_type_with_stride (struct type *result_type,
- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
- low_bound = high_bound = 0;
- element_type = check_typedef (element_type);
-+
- /* Be careful when setting the array length. Ada arrays can be
- empty arrays with the high_bound being smaller than the low_bound.
- In such cases, the array length should be zero. */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
-@@ -803,7 +803,6 @@ struct main_type
- /* * Union member used for range types. */
+@@ -1615,6 +1615,15 @@ extern unsigned type_align (struct type *);
+ space in struct type. */
+ extern bool set_type_align (struct type *, ULONGEST);
- struct range_bounds *bounds;
--
- } flds_bnds;
-
- /* * Slot to point to additional language-specific fields of this
-@@ -1365,6 +1364,15 @@ extern bool set_type_align (struct type *, ULONGEST);
- #define TYPE_BIT_STRIDE(range_type) \
- (TYPE_RANGE_DATA(range_type)->stride.data.const_val \
- * (TYPE_RANGE_DATA(range_type)->flag_is_byte_stride ? 8 : 1))
+#define TYPE_BYTE_STRIDE(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.data.const_val
+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
+#define TYPE_BYTE_STRIDE_KIND(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.kind
+
-
/* Property accessors for the type data location. */
#define TYPE_DATA_LOCATION(thistype) \
-@@ -1400,6 +1408,9 @@ extern bool set_type_align (struct type *, ULONGEST);
- TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
- #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
- TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
+ ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
+@@ -1633,6 +1642,26 @@ extern bool set_type_align (struct type *, ULONGEST);
+ #define TYPE_ASSOCIATED_PROP(thistype) \
+ ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
+
++/* Accessors for struct range_bounds data attached to an array type's
++ index type. */
++
++#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
++ ((arraytype)->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED)
++#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
++ (arraytype->index_type ()->bounds ().low.kind () == PROP_UNDEFINED)
+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
-+ (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
++ (TYPE_BYTE_STRIDE(arraytype->index_type ()) == 0)
++
++
++#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
++ (TYPE_HIGH_BOUND((arraytype)->index_type ()))
+
++#define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
++ (TYPE_LOW_BOUND((arraytype)->index_type ()))
++
++#define TYPE_ARRAY_BIT_STRIDE(arraytype) \
++ (TYPE_BIT_STRIDE((arraytype)->index_type ()))
++
+ /* C++ */
- #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
- (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
+ #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
diff --git a/gdb/parse.c b/gdb/parse.c
--- a/gdb/parse.c
+++ b/gdb/parse.c
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
-@@ -1224,13 +1224,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
+@@ -1082,13 +1082,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
*pos += 3;
- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
- low = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ low = evaluate_subexp (nullptr, exp, pos, noside);
- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
+ if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
- high = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ high = evaluate_subexp (nullptr, exp, pos, noside);
- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
+ bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE));
if (noside == EVAL_SKIP)
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
-@@ -1319,7 +1317,7 @@ rust_compute_range (struct type *type, struct value *range,
+@@ -1177,7 +1175,7 @@ rust_compute_range (struct type *type, struct value *range,
*low = 0;
*high = 0;
- *kind = BOTH_BOUND_DEFAULT;
+ *kind = SUBARRAY_NONE_BOUND;
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return;
-@@ -1327,15 +1325,14 @@ rust_compute_range (struct type *type, struct value *range,
+@@ -1185,15 +1183,14 @@ rust_compute_range (struct type *type, struct value *range,
i = 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
{
*low = value_as_long (value_field (range, 0));
++i;
}
- if (TYPE_NFIELDS (type) > i
+ if (type->num_fields () > i
&& strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
{
- *kind = (*kind == BOTH_BOUND_DEFAULT
*high = value_as_long (value_field (range, i));
if (rust_inclusive_range_type_p (type))
-@@ -1353,7 +1350,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
+@@ -1211,7 +1208,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
LONGEST high = 0;
int want_slice = 0;
-@@ -1451,7 +1448,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
+@@ -1309,7 +1306,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
error (_("Cannot subscript non-array type"));
if (want_slice
low = low_bound;
if (low < 0)
error (_("Index less than zero"));
-@@ -1469,7 +1466,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
+@@ -1327,7 +1324,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
CORE_ADDR addr;
struct value *addrval, *tem;
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
-@@ -32,7 +32,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
+@@ -35,7 +35,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
gdb_test "print sizeof(vla1(3,2,1))" \
"no such vector element \\(vector not allocated\\)" \
"print sizeof non-allocated indexed vla1"
"print sizeof non-allocated sliced vla1"
# Try to access value in allocated VLA
-@@ -41,7 +42,7 @@ gdb_continue_to_breakpoint "vla1-allocated"
+@@ -44,7 +45,7 @@ gdb_continue_to_breakpoint "vla1-allocated"
gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
gdb_test "print sizeof(vla1(3,2,1))" "4" \
"print sizeof element from allocated vla1"
"print sizeof sliced vla1"
# Try to access values in undefined pointer to VLA (dangling)
-@@ -49,7 +50,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
+@@ -52,7 +53,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
gdb_test "print sizeof(pvla(3,2,1))" \
"no such vector element \\(vector not associated\\)" \
"print sizeof non-associated indexed pvla"
"print sizeof non-associated sliced pvla"
# Try to access values in pointer to VLA and compare them
-@@ -58,7 +60,8 @@ gdb_continue_to_breakpoint "pvla-associated"
+@@ -61,7 +63,8 @@ gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
gdb_test "print sizeof(pvla(3,2,1))" "4" \
"print sizeof element from associated pvla"
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
-@@ -3797,13 +3797,42 @@ value_of_this_silent (const struct language_defn *lang)
+@@ -3756,13 +3756,42 @@ value_of_this_silent (const struct language_defn *lang)
struct value *
value_slice (struct value *array, int lowbound, int length)
- array_type = check_typedef (value_type (array));
+ /* Check for legacy code if we are actually dealing with an array or
+ string. */
- if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY
- && TYPE_CODE (array_type) != TYPE_CODE_STRING)
+ if (array_type->code () != TYPE_CODE_ARRAY
+ && array_type->code () != TYPE_CODE_STRING)
error (_("cannot take slice of non-array"));
-@@ -3813,45 +3842,155 @@ value_slice (struct value *array, int lowbound, int length)
+@@ -3772,45 +3801,155 @@ value_slice (struct value *array, int lowbound, int length)
if (type_not_associated (array_type))
error (_("array not associated"));
-- range_type = TYPE_INDEX_TYPE (array_type);
-- if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
+- range_type = array_type->index_type ();
+- if (!get_discrete_bounds (range_type, &lowerbound, &upperbound))
- error (_("slice from bad array or bitstring"));
-+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (array_type));
-+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (array_type));
++ ary_low_bound = array_type->index_type ()->bounds ()->low.const_val ();
++ ary_high_bound = array_type->index_type ()->bounds ()->high.const_val ();
+
+ /* When we are working on a multi-dimensional array, we need to get the
+ attributes of the underlying type. */
+ if (call_count > 1)
+ {
-+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (elt_type));
-+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (elt_type));
++ ary_low_bound = elt_type->index_type ()->bounds ()->low.const_val ();
++ ary_high_bound = elt_type->index_type ()->bounds ()->high.const_val ();
+ elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
+ row_count = TYPE_LENGTH (array_type)
+ / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
+
+ elt_size = TYPE_LENGTH (elt_type);
+ elt_offs = lowbound - ary_low_bound;
++
++ elt_offs *= elt_size;
- if (lowbound < lowerbound || length < 0
- || lowbound + length - 1 > upperbound)
- error (_("slice out of range"));
-+ elt_offs *= elt_size;
-+
+ /* Check for valid user input. In case of Fortran this was already done
+ in the calling function. */
+ if (call_count == 1
+ array by setting slice_range_size. */
+ if (call_count == 1)
+ {
-+ range_type = TYPE_INDEX_TYPE (array_type);
++ range_type = array_type->index_type ();
+ slice_range_size = ary_low_bound + elem_count - 1;
+
+ /* Check if the array bounds are valid. */
+ accordingly. */
+ else
+ {
-+ range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type));
++ range_type = TYPE_TARGET_TYPE (array_type)->index_type ();
+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1;
-+ ary_low_bound = TYPE_LOW_BOUND (range_type);
++ ary_low_bound = range_type->bounds ()->low.const_val ();
+ }
/* FIXME-type-allocation: need a way to free this type when we are
- LONGEST offset
- = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
+ struct type *element_type;
-+
+
+- slice_type = create_array_type (NULL,
+- element_type,
+- slice_range_type);
+- slice_type->set_code (array_type->code ());
+ /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy
+ code for subarrays. */
+ if (call_count == 1 && stride_length == 1)
+ element_type = TYPE_TARGET_TYPE (array_type);
+
+ slice_type = create_array_type (NULL, element_type, slice_range_type);
-
-- slice_type = create_array_type (NULL,
-- element_type,
-- slice_range_type);
-- TYPE_CODE (slice_type) = TYPE_CODE (array_type);
-+ TYPE_CODE (slice_type) = TYPE_CODE (array_type);
++
++ slice_type->set_code (array_type->code ());
- if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
- slice = allocate_value_lazy (slice_type);
+
+ slice_type = create_array_type (NULL, element_type, slice_range_type);
+
-+ /* If we have a one dimensional array, we copy its TYPE_CODE. For a
-+ multi dimensional array we copy the embedded type's TYPE_CODE. */
++ /* If we have a one dimensional array, we copy its type code. For a
++ multi dimensional array we copy the embedded type's type code. */
+ if (call_count == 1)
-+ TYPE_CODE (slice_type) = TYPE_CODE (array_type);
++ slice_type->set_code (array_type->code ());
+ else
-+ TYPE_CODE (slice_type) = TYPE_CODE (TYPE_TARGET_TYPE (array_type));
++ slice_type->set_code ((TYPE_TARGET_TYPE (array_type)->code ()));
+
+ v = allocate_value (slice_type);
+
+ return v;
}
- /* Create a value for a FORTRAN complex number. Currently most of the
+ /* See value.h. */
diff --git a/gdb/value.h b/gdb/value.h
--- a/gdb/value.h
+++ b/gdb/value.h
-@@ -1145,6 +1145,8 @@ extern struct value *varying_to_slice (struct value *);
+@@ -1144,6 +1144,8 @@ extern struct value *varying_to_slice (struct value *);
extern struct value *value_slice (struct value *, int, int);
+extern struct value *value_slice_1 (struct value *, int, int, int, int);
+
- extern struct value *value_literal_complex (struct value *, struct value *,
- struct type *);
-
+ /* Create a complex number. The type is the complex type; the values
+ are cast to the underlying scalar type before the complex number is
+ created. */