This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] factor common code in signed_or_unsigned
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Rafael Espindola <espindola at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Mar 2007 09:46:37 -0700
- Subject: Re: [PATCH] factor common code in signed_or_unsigned
- References: <38a0d8450703230954x3fec52ddyc72c9310426abde6@mail.gmail.com>
Rafael Espindola wrote:
> The attached patch factors common code to many signed_or_unsigned
> language hooks. It also adds a default implementation that is used by
> all non C/C++ frontends.
Missing ChangeLog.
> +tree
> +get_signed_or_unsigned_type (int unsignedp, tree type)
> +{
> + if (!INTEGRAL_TYPE_P (type) || TYPE_UNSIGNED (type) == unsignedp)
> + return type;
> +
> + return lang_hooks.types.signed_or_unsigned_type(unsignedp, type);
> +}
> +
> +tree
> +lhd_signed_or_unsigned_type (int unsignedp, tree type)
> +{
> + return lang_hooks.types.type_for_size (TYPE_PRECISION (type), unsignedp);
> +}
These functions need comments. Say what each parameter is and what the
return value is, e.g.:
/* If TYPE is an integral type, return an equivalent type which is
unsigned iff UNSIGNEDP is true. If TYPE is not an integral type,
return TYPE itself. */
The patch will be OK with these changes; the idea is good.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713