This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada subtypes and base types
On 3/23/06, Jeffrey A Law <law@redhat.com> wrote:
> On Thu, 2006-03-23 at 10:40 +0100, Duncan Sands wrote:
> > Hi Jeff, this seems to work nicely - thanks again. I still see a bunch
> > of suboptimal range calculations in the Ada code I'm looking at, but these
> > now just coming from having everything initialised to VR_VARYING rather than
> > [TYPE_MIN, TYPE_MAX]. Do you know of any way of getting variables with
> > non-trivial TYPE_MIN/TYPE_MAX values in C? I ask because I'd rather produce
> > test cases in C than Ada, since everyone has access to a C compiler :)
> You can't -- min/max will be extended to cover the type's precision,
> even for enumerated types.
>
> enum x
> {
> RED == 0,
> GREEN = 1,
> BLUE = 2,
> PURPLE = 3,
> }
>
> for (color = RED, color <= PURPLE; color++)
> {
> ...
> }
>
> Note carefully that for the loop test to terminate that color
> will have the value PURPLE+1 (4). If the type min/max were set to
> 0, 3 respectively then the loop exit test would be optimized away...
Well - we could hack a new type attribute to specify min/max values...
Richard.