===================================================================
@@ -4740,8 +4743,15 @@ output_constructor_regular_field (oc_loc
if (local->index != NULL_TREE)
{
- double_int idx = double_int_sub (tree_to_double_int (local->index),
- tree_to_double_int
(local->min_index));
+ /* ??? Ada has negative DECL_FIELD_OFFSETs but we are using an
+ unsigned sizetype so make sure to sign-extend the indices before
+ subtracting them. */
+ unsigned prec = TYPE_PRECISION (sizetype);
+ double_int idx
+ = double_int_sub (double_int_sext (tree_to_double_int
(local->index),
+ prec),
+ double_int_sext (tree_to_double_int
+ (local->min_index), prec));
gcc_assert (double_int_fits_in_shwi_p (idx));