This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] adjust warning_n() to take uhwi (PR 84207)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 Feb 2018 21:05:34 +0000
- Subject: Re: [PATCH] adjust warning_n() to take uhwi (PR 84207)
- Authentication-results: sourceware.org; auth=none
- References: <7c200219-2d6e-02ca-e720-9d3a8616a1e6@gmail.com>
On Mon, 12 Feb 2018, Martin Sebor wrote:
> Bug 84207 - Hard coded plural in gimple-fold.c points out one
> of a number of warning_at() calls where warning_n() should have
> been used. The attached patch both replaces the calls and also
> changes the signatures of the warning_n(), error_n(), and
> inform_n() functions to take an unsigned HOST_WIDE_INT argument
> instead of int. I also changed the implementation of
> diagnostic_n_impl() to deal with unsigned HOST_WIDE_INT values
> in excess of ULONG_MAX (the maximum value ngettext handles) so
> callers don't need to.
Saturating to ULONG_MAX is not correct for languages where the plural form
depends on n%10 or n%100 (see the various Plural-Forms entries in the .po
files). If n is too large you want something like n % 1000000 + 1000000
instead to get the correct plural form in all cases.
--
Joseph S. Myers
joseph@codesourcery.com