This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ada] Avoid doing arithmetics in ENUMERAL_TYPE
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 23 Apr 2009 11:02:36 +0200
- Subject: Re: [Ada] Avoid doing arithmetics in ENUMERAL_TYPE
- References: <200904230036.37032.ebotcazou@adacore.com>
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
>