[Ada] Avoid doing arithmetics in ENUMERAL_TYPE
Eric Botcazou
ebotcazou@adacore.com
Wed Apr 22 22:44:00 GMT 2009
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.
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 2231 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090422/d3d16997/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enum2.adb
Type: text/x-adasrc
Size: 274 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090422/d3d16997/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enum2_pkg.ads
Type: text/x-adasrc
Size: 237 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090422/d3d16997/attachment-0002.bin>
More information about the Gcc-patches
mailing list