[Ada] Fix problem in convert_with_check

Eric Botcazou ebotcazou@adacore.com
Sat Mar 4 18:28:00 GMT 2006


It's one of the problems uncovered by Jeff with his Ada-killer patch. :-)

In a few cases, Gigi builds types that are not present in the Ada source.
convert_with_check was converting the expression to be checked to the Ada
base type (present in the source) instead of the real base type, which
can lead to the following GIMPLE code:

            D.756 = for_the_value /[rd] 1000000000;
            D.757 = (UNSIGNED_64) D.756;
            if (D.757 > 255)
              {
                __gnat_rcheck_10 ("c460008.adb", 35);
                iftmp.5 = for_the_value /[rd] 1000000000;
              }
            else
              {
                iftmp.5 = for_the_value /[rd] 1000000000;
              }
            iftmp.6 = iftmp.5;
            if (0)
              {
                goto <D760>;
              }
            else
              {
                
              }
            D.763 = (c460008__unsigned_edge_8) iftmp.6;
            D.764 = (c460008__unsigned_edge_8___UMT) D.763;
            if (D.764 > 254)
              {
                goto <D760>;
              }
            else
              {
                goto <D761>;
              }
            <D760>:;
            __gnat_rcheck_12 ("c460008.adb", 35);

This is problematic because the expression in the original type iftmp.6
is converted to the (Ada base) type c460008__unsigned_edge_8 before the
check in the real type c460008__unsigned_edge_8___UMT that would validate
the conversion, thus potentially allowing objects of the former type to
have values outside its TYPE_MIN_VALUE..TYPE_MAX_VALUE range.

The change fixes ACATS c460008 and c460011 at -O2 so we are left with:

                === acats tests ===
FAIL:   c34004a
FAIL:   c46033a
FAIL:   cdd2a02
FAIL:   cxa4025
FAIL:   cxa4028
FAIL:   cxa4033
FAIL:   cxg2024

                === acats Summary ===
# of expected passes            2309
# of unexpected failures        7

of which cdd2a02 should be considered nominal.

Bootstrapped/regtested on x86, applied to mainline.


2006-03-04  Eric Botcazou  <ebotcazou@adacore.com>

	* gigi.h (get_ada_base_type): Delete.
        * utils2.c (get_ada_base_type): Likewise.
        * trans.c (convert_with_check): Operate in the real base type.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f303-013-2_41.diff
Type: text/x-diff
Size: 3003 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060304/71385864/attachment.bin>


More information about the Gcc-patches mailing list