[PATCH] Improve PR30911 and PR31023, Ada and VRP

Eric Botcazou ebotcazou@adacore.com
Mon Mar 31 21:23:00 GMT 2008


> So should Richard apply his patch then?

I'd say yes, ACATS is clean at -O2 so let's try.  In fact the compiler already 
implements something equivalent in specific cases, for example:

package Values is

   type Range_Type is range 1 .. 2;
   for Range_Type'Size use 8;

   function Is_Valid (X : Range_Type) return Boolean;

end;

package body Values is

   function Is_Valid (X : Range_Type) return Boolean is
   begin
      case Integer(X) is
         when 1      => return True;
         when 2      => return True;
         when others => return False;
      end case;
   end;

end;

is optimized to "return True;" at -O, so there won't be any quantum leap.

Moreover, even if this is a little experimental, I think that this will help 
us to understand the limits of the current implementation of Ada subtypes.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list