This is the mail archive of the gcc-patches@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: [Ada] Avoid doing arithmetics in ENUMERAL_TYPE


On Thu, Apr 23, 2009 at 12:36 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> For
>
> ? ? [subtype p__T34b is p__enum range b .. c]
> ? ? ?R45b : p__T34b := b;
> ? ? ?R45b := p__T34b'succ(R45b);
>
> Gigi generates an additive expression in an enumeral type:
>
> ?R45b = (p__T34b___XDLU_1__2) ((p__enum) R45b + 1);
>
> and this is a no-no for non-standard precisions.

At least if TYPE_MIN/MAX_VALUE does not cover all of
TYPE_PRECISION.  Otherwise the middle-end treats
all integer types as exchangable.

Richard.

>
> Tested on i586-suse-linux, applied on the mainline and 4.4 branch.
>
>
> 2009-04-22 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* gcc-interface/utils2.c (build_binary_op) <PLUS_EXPR>: If operation's
> ? ? ? ?type is an enumeral or a boolean type, change it to an integer type
> ? ? ? ?with the same mode and signedness.
>
>
> 2009-04-22 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* gnat.dg/enum2.adb: New test.
> ? ? ? ?* gnat.dg/enum2_pkg.ads: New helper.
>
>
> --
> Eric Botcazou
>


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