This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix bug in int_fits_type_p
- From: Ian Lance Taylor <ian at airs dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 08 Nov 2005 10:12:07 -0800
- Subject: Re: [PATCH] Fix bug in int_fits_type_p
- References: <200511081551.18001.ebotcazou@adacore.com>
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