This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada subtypes and base types
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Sebastian Pop <sebastian dot pop at cri dot ensmp dot fr>
- Cc: Jeffrey A Law <law at redhat dot com>, Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, gcc at gcc dot gnu dot org
- Date: Sat, 25 Feb 2006 09:48:40 +0100
- Subject: Re: Ada subtypes and base types
- References: <20060224184736.GB5239@napoca.cri.ensmp.fr>
Hello,
> Jeffrey A Law wrote:
> > Another possibility is to simply not allow conversions between a
> > subtype and basetype.
>
> Such a patch also solves the problem. But I'm not sure to understand
> the impact on other codes. Is this kind of conversion between a type
> and its basetype specific to Ada?
this still seems unnecessarily conservative to me. I would just check
for types whose TYPE_MIN and TYPE_MAX do not match the natural values
derived from the type precision (i.e., those returned by
upper_bound_in_type (type, type) and lower_bound_in_type (type, type)).
Zdenek
> Index: tree-chrec.c
> ===================================================================
> --- tree-chrec.c (revision 111416)
> +++ tree-chrec.c (working copy)
> @@ -1207,7 +1207,9 @@ chrec_convert_aggressive (tree type, tre
> return NULL_TREE;
>
> inner_type = TREE_TYPE (chrec);
> - if (TYPE_PRECISION (type) > TYPE_PRECISION (inner_type))
> + if (TYPE_PRECISION (type) > TYPE_PRECISION (inner_type)
> + /* Conversions between a subtype and its basetype are not allowed. */
> + || TREE_TYPE (type) == TREE_TYPE (chrec))
> return NULL_TREE;
>
> left = CHREC_LEFT (chrec);