This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v2] gcc/c-family/c-cppbuiltin.c: Let buffer enough to print host wide integer value
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: rth at redhat dot com, Jeff Law <law at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 25 Nov 2014 08:25:01 +0800
- Subject: Re: [PATCH v2] gcc/c-family/c-cppbuiltin.c: Let buffer enough to print host wide integer value
- Authentication-results: sourceware.org; auth=none
OK, thank you for your work, I shall send patch v3 for it.
Send from Lenovo A788t.
Joseph Myers <joseph@codesourcery.com> wrote:
>On Sun, 23 Nov 2014, Chen Gang wrote:
>
>> + gcc_assert (wi::fits_to_tree_p(value, integer_type_node));
>
>Watch formatting: space before '(' in the wi::fits_to_tree_p call.
>Applies elsewhere in this patch as well.
>
>When making such an interface change, (a) you should update the comment on
>builtin_define_with_int_value to explain the new interface, and (b) you
>should check existing callers to make sure their values are indeed in
>range, and describe the check you did.
>
>In fact, -fabi-version=0 results in __GXX_ABI_VERSION being defined to
>999999 using builtin_define_with_int_value. That's out of range of int on
>targets with 16-bit int. So that indicates against requiring the value to
>be within range of int. It might however be OK to require the value to be
>within range of target long.
>
>> + if (value >= 0)
>> + {
>> + sprintf (buf, "%s="HOST_WIDE_INT_PRINT_DEC"%s",
>> + macro, value,
>> + value <= HOST_INT_MAX
>> + ? ""
>> + : value <= HOST_LONG_MAX
>> + ? "L" : "LL");
>
>Limits on the host's int and long are completely irrelevant here. The
>question is the target's int and long, not the host's - and consistency
>indicates checking with wi::fits_to_tree_p (value, integer_type_node) if
>the assertion checked with long_integer_type_node.
>
>--
>Joseph S. Myers
>joseph@codesourcery.com