gcc/cp/pt.c: use ngettext() when needed
Marco Poletti
poletti.marco@gmail.com
Mon Feb 22 09:38:00 GMT 2010
2010/2/18 Marco Poletti <poletti.marco@gmail.com>:
> 2010/2/18 Jakub Jelinek <jakub@redhat.com>:
>> On Thu, Feb 18, 2010 at 03:33:34PM +0100, Marco Poletti wrote:
>>> --- gcc/diagnostic.c (revisione 156858)
>>> +++ gcc/diagnostic.c (copia locale)
>>> @@ -519,6 +519,23 @@ inform (location_t location, const char
>>> va_end (ap);
>>> }
>>>
>>> +/* An informative note at LOCATION. Use this for additional details
>>> on an error
>>
>> Too long line.
>>
>>> + message. The message is already translated. */
>>
>> The message is not translated, inform_n does the translation.
>>
>>> +/* A hard error: the code is definitely ill-formed, and an object file
>>> + will not be produced. The message is already translated. */
>>
>> Likewise.
>>
>> Jakub
>>
>
> @Jakub:
> Yes, you're right. Thanks for pointing these out.
>
> Updated patch:
>
> Index: gcc/diagnostic.c
> ===================================================================
> --- gcc/diagnostic.c (revisione 156858)
> +++ gcc/diagnostic.c (copia locale)
> @@ -519,6 +519,23 @@ inform (location_t location, const char
> va_end (ap);
> }
>
> +/* An informative note at LOCATION. Use this for additional details on an
> + error message. */
> +void
> +inform_n (location_t location, int n, const char *singular_gmsgid,
> + const char *plural_gmsgid, ...)
> +{
> + diagnostic_info diagnostic;
> + va_list ap;
> +
> + va_start (ap, plural_gmsgid);
> + diagnostic_set_info_translated (&diagnostic,
> + ngettext (singular_gmsgid, plural_gmsgid, n),
> + &ap, location, DK_NOTE);
> + report_diagnostic (&diagnostic);
> + va_end (ap);
> +}
> +
> /* A warning at INPUT_LOCATION. Use this for code which is correct according
> to the relevant language specification but is likely to be buggy anyway.
> Returns true if the warning was printed, false if it was inhibited. */
> @@ -613,6 +630,23 @@ error (const char *gmsgid, ...)
> report_diagnostic (&diagnostic);
> va_end (ap);
> }
> +
> +/* A hard error: the code is definitely ill-formed, and an object file
> + will not be produced. */
> +void
> +error_n (location_t location, int n, const char *singular_gmsgid,
> + const char *plural_gmsgid, ...)
> +{
> + diagnostic_info diagnostic;
> + va_list ap;
> +
> + va_start (ap, plural_gmsgid);
> + diagnostic_set_info_translated (&diagnostic,
> + ngettext (singular_gmsgid, plural_gmsgid, n),
> + &ap, location, DK_ERROR);
> + report_diagnostic (&diagnostic);
> + va_end (ap);
> +}
>
> /* Same as ebove, but use location LOC instead of input_location. */
> void
> Index: gcc/toplev.h
> ===================================================================
> --- gcc/toplev.h (revisione 156858)
> +++ gcc/toplev.h (copia locale)
> @@ -63,6 +63,8 @@ extern bool warning (int, const char *,
> extern bool warning_at (location_t, int, const char *, ...)
> ATTRIBUTE_GCC_DIAG(3,4);
> extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
> +extern void error_n (location_t, int, const char *, const char *, ...)
> + ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
> extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
> extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
> ATTRIBUTE_NORETURN;
> @@ -72,6 +74,8 @@ extern bool pedwarn (location_t, int, co
> extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
> extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
> extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
> +extern void inform_n (location_t, int, const char *, const char *, ...)
> + ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
> extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
>
> extern void rest_of_decl_compilation (tree, int, int);
> Index: gcc/cp/pt.c
> ===================================================================
> --- gcc/cp/pt.c (revisione 156858)
> +++ gcc/cp/pt.c (copia locale)
> @@ -4614,10 +4614,14 @@ redeclare_class_template (tree type, tre
>
> if (TREE_VEC_LENGTH (parms) != TREE_VEC_LENGTH (tmpl_parms))
> {
> - error ("redeclared with %d template parameter(s)",
> - TREE_VEC_LENGTH (parms));
> - inform (input_location, "previous declaration %q+D used %d
> template parameter(s)",
> - tmpl, TREE_VEC_LENGTH (tmpl_parms));
> + error_n (input_location, TREE_VEC_LENGTH (parms),
> + "redeclared with %d template parameter",
> + "redeclared with %d template parameters",
> + TREE_VEC_LENGTH (parms));
> + inform_n (input_location, TREE_VEC_LENGTH (tmpl_parms),
> + "previous declaration %q+D used %d template parameter",
> + "previous declaration %q+D used %d template parameters",
> + tmpl, TREE_VEC_LENGTH (tmpl_parms));
> return false;
> }
>
> Index: gcc/po/exgettext
> ===================================================================
> --- gcc/po/exgettext (revisione 156858)
> +++ gcc/po/exgettext (copia locale)
> @@ -112,6 +112,8 @@ function keyword_option(line) {
> else if (args ~ /c$/)
> format="c-format"
>
> + if (name ~ /_n$/) n = n "," (n + 1)
> +
> if (n == 1) { keyword = "--keyword=" name }
> else { keyword = "--keyword=" name ":" n }
> if (format) {
>
PING!
Can someone comment on this or commit it?
Marco Poletti
More information about the Gcc-patches
mailing list