This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tree CONSTRUCTORs and Ada array indices


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]