This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Tree CONSTRUCTORs and Ada array indices
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: gcc at gcc dot gnu dot org, Alan Lawrence <alan dot lawrence at arm dot com>
- Date: Thu, 15 Oct 2015 12:44 +0200
- Subject: Re: Tree CONSTRUCTORs and Ada array indices
- Authentication-results: sourceware.org; auth=none
- References: <561E5069 dot 6020901 at arm dot com> <3012207 dot TkQ4nhYs2N at polaris> <CAFiYyc0DpODvpq5OK8kX+osVpfZy1Z3FdrY5eif7uggtVN9haQ at mail dot gmail dot com>
> C/C++ empty arrays (int a[0]) now use a signed TYPE_DOMAIN with bounds [0,
> -1] for example (that was my original motivation to make hopefully all of
> the middle-end
> work with ssizetype TYPE_DOMAINs at least). The tree.c range-type build
> helpers accept all integral types now (but most FEs use sizetype or
> ssizetype).
Using ssizetype in Ada would already be a net progress, I'll investigate.
> ISTR also doing some Ada adjustments but they may have been dumped for
> "interesting" changes to stor-layout.c instead:
>
> /* ??? When it is obvious that the range is signed
> represent it using ssizetype. */
> if (TREE_CODE (lb) == INTEGER_CST
> && TREE_CODE (ub) == INTEGER_CST
> && TYPE_UNSIGNED (TREE_TYPE (lb))
> && tree_int_cst_lt (ub, lb))
> {
> lb = wide_int_to_tree (ssizetype,
> offset_int::from (lb, SIGNED));
> ub = wide_int_to_tree (ssizetype,
> offset_int::from (ub, SIGNED));
> }
> length
> = fold_convert (sizetype,
> size_binop (PLUS_EXPR,
> build_int_cst (TREE_TYPE (lb),
> 1), size_binop (MINUS_EXPR, ub, lb))); }
>
> /* ??? We have no way to distinguish a null-sized array from an
> array spanning the whole sizetype range, so we arbitrarily
> decide that [0, -1] is the only valid representation. */
> if (integer_zerop (length)
> && TREE_OVERFLOW (length)
> && integer_zerop (lb))
> length = size_zero_node;
IIRC the first one is yours and the second one is mine. :-) But, yes, they
clearly should go and be replaced by changes in gigi.
--
Eric Botcazou