This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ada subtypes and base types


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?

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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]