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] factor common code in signed_or_unsigned


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


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