This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Q about Ada and value ranges in types
- From: ja2morri at csclub dot uwaterloo dot ca (James A. Morrison)
- To: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Cc: dnovillo at redhat dot com, gcc at gcc dot gnu dot org
- Date: 27 Jun 2005 19:36:09 -0400
- Subject: Re: Q about Ada and value ranges in types
- References: <10506272049.AA09083@vlsi1.ultra.nyu.edu>
kenner@vlsi1.ultra.nyu.edu (Richard Kenner) writes:
> Sorry it took me so long to get to this.
>
> > You're not showing where this comes from, so it's hard to say. However
> > D.1480 is created by the gimplifier, not the Ada front end. There could
> > easily be a typing problem in the tree there (e.g., that of the
> > subtraction) but I can't tell for sure.
>
> As it turned out, there was.
>
> So, after calling sinfo__chars() and subtracting 300000361, the
> FE is emitting that range check. AFAICT, the call to
> sinfo__chars(e_5) comes from ada/sem_intr.adb:148
>
> Nam : constant Name_Id := Chars (E);
>
> and 'if (D.1480_32 <= 1)' is at line 155:
>
> I'd also assumed this was where the bogus tree came from, but I was wrong.
> The node in question was not made by the Ada front end but by
> build_range_check in clearly incorrect code that does the subtraction in the
> wrong type.
>
> This fixes that problem. Are you in a position to check if it fixes the
> original issue?
>
> *** fold-const.c 25 Jun 2005 01:59:57 -0000 1.599
> --- fold-const.c 27 Jun 2005 20:44:56 -0000
> *************** build_range_check (tree type, tree exp,
> *** 4027,4034 ****
>
> if (value != 0 && ! TREE_OVERFLOW (value))
> ! return build_range_check (type,
> ! fold_build2 (MINUS_EXPR, etype, exp, low),
> ! 1, fold_convert (etype, integer_zero_node),
> ! value);
>
> return 0;
> --- 4027,4045 ----
>
> if (value != 0 && ! TREE_OVERFLOW (value))
> ! {
> ! /* There is no requirement that LOW be within the range of ETYPE
> ! if the latter is a subtype. It must, however, be within the base
> ! type of ETYPE. So be sure we do the subtraction in that type. */
> ! if (TREE_TYPE (etype))
> ! {
> ! etype = TREE_TYPE (etype);
> ! value = fold_convert (etype, value);
> ! }
> !
> ! return build_range_check (type,
> ! fold_build2 (MINUS_EXPR, etype, exp, low),
> ! 1, fold_convert (etype, integer_zero_node),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RTH has been suggesting to use build_int_cst (etype, 0) instead.
> ! value);
> ! }
>
> return 0;
>
--
Thanks,
Jim
http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim