This is the mail archive of the gcc-patches@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: [PATCH] Fix bug in int_fits_type_p


Eric Botcazou <ebotcazou@adacore.com> writes:

> Index: tree.c
> ===================================================================
> --- tree.c	(revision 106397)
> +++ tree.c	(working copy)
> @@ -5542,7 +5542,13 @@ int_fits_type_p (tree c, tree type)
>    /* If we haven't been able to decide at this point, there nothing more we
>       can check ourselves here. Look at the base type if we have one.  */
>    if (TREE_CODE (type) == INTEGER_TYPE && TREE_TYPE (type) != 0)
> -    return int_fits_type_p (c, TREE_TYPE (type));
> +    {
> +      tree base_type = TREE_TYPE (type);
> +      if (TYPE_PRECISION (base_type) != TYPE_PRECISION (type))
> +	base_type = lang_hooks.types.type_for_size (TYPE_PRECISION (type),
> +						    TYPE_UNSIGNED (type));
> +      return int_fits_type_p (c, base_type);
> +    }
>  
>    /* Or to force_fit_type, if nothing else.  */
>    tmp = copy_node (c);

Would it work to just say
  if (TREE_CODE (type) == INTEGER_TYPE
      && TREE_TYPE (type) != 0
      && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (type)))
?

Would that be better?

I don't really know.  I'd be interested in hearing any other opinions.
I'm not fully clear on the relationship between an integer type and
the TREE_TYPE of that integer type.

Ian


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