+2020-11-04 Tom Tromey <tromey@adacore.com>
+
+ * ada-lang.c (ada_is_any_packed_array_type): New function.
+ (ada_evaluate_subexp) <case TERNOP_SLICE>: Use it.
+
2020-11-04 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (recognize_bound_expression)
return 0;
}
+/* Return true if TYPE is a (Gnat-encoded) constrained packed array
+ type, or if it is an ordinary (non-Gnat-encoded) packed array. */
+
+static bool
+ada_is_any_packed_array_type (struct type *type)
+{
+ return (ada_is_constrained_packed_array_type (type)
+ || (type->code () == TYPE_CODE_ARRAY
+ && TYPE_FIELD_BITSIZE (type, 0) % 8 != 0));
+}
+
/* Given that TYPE encodes a packed array type (constrained or unconstrained),
return the size of its elements in bits. */
TYPE_TARGET_TYPE (value_type (array)) =
ada_aligned_type (TYPE_TARGET_TYPE (value_type (array)));
- if (ada_is_constrained_packed_array_type (value_type (array)))
+ if (ada_is_any_packed_array_type (value_type (array)))
error (_("cannot slice a packed array"));
/* If this is a reference to an array or an array lvalue,
+2020-11-04 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/mod_from_name.exp: Test printing slice.
+
2020-11-04 Tom Tromey <tromey@adacore.com>
* gdb.ada/O2_float_param.exp: Test different -fgnat-encodings
}
gdb_test "print xp" \
"= \\(y => \\(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10\\)\\)"
+ gdb_test "print slice" "cannot slice a packed array"
}