* gcc/cp/pt.c: use ngettext() when needed
@ 2010-02-17 15:23 Marco Poletti
2010-02-17 15:25 ` Marco Poletti
2010-02-17 17:06 ` Gabriel Dos Reis
0 siblings, 2 replies; 30+ messages in thread
From: Marco Poletti @ 2010-02-17 15:23 UTC (permalink / raw)
To: gcc-patches
In the file pt.c, there were translatable strings like "redeclared
with %d template parameter(s)" that are hard to translate.
Instead, it should use the ngettext() function to allow more flexible
translations.
I've added two functions inform_translated() and error_translated() to
diagnostic.c, that are called by pt.c.
This is my second patch to GCC, I could have done something wrong.
Critics are very appreciated.
Changelog for gcc/cp/:
* pt.c (redeclare_class_template): Use inform_translated and
error_translated
Changelog for gcc/
* diagnostic.h (inform_translated): Declare.
(error_translated): Declare.
* diagnostic.c (inform_translated): New function.
(error_translated): New function.
Patch:
Index: gcc/diagnostic.c
===================================================================
--- gcc/diagnostic.c (revisione 156824)
+++ gcc/diagnostic.c (copia locale)
@@ -519,6 +519,20 @@ inform (location_t location, const char
va_end (ap);
}
+/* An informative note at LOCATION. Use this for additional details
on an error
+ message. The message is already translated. */
+void
+inform_translated (location_t location, const char *gmsgid, ...)
+{
+ diagnostic_info diagnostic;
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ diagnostic_set_info_translated (&diagnostic, gmsgid, &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 +627,21 @@ 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. The message is already translated. */
+void
+error_translated (const char *gmsgid, ...)
+{
+ diagnostic_info diagnostic;
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ diagnostic_set_info_translated (&diagnostic, gmsgid, &ap, input_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 156824)
+++ gcc/toplev.h (copia locale)
@@ -63,6 +63,7 @@ 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_translated (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
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 +73,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_translated (location_t, const char *, ...)
+ATTRIBUTE_GCC_DIAG(2,3);
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 156824)
+++ gcc/cp/pt.c (copia locale)
@@ -4614,10 +4614,15 @@ 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_translated (ngettext ("redeclared with %d template parameter",
+ "redeclared with %d template parameters",
+ TREE_VEC_LENGTH (parms)),
+ TREE_VEC_LENGTH (parms));
+ inform_translated (input_location,
+ ngettext("previous declaration %q+D used %d
template parameter",
+ "previous declaration %q+D used %d
template parameters",
+ TREE_VEC_LENGTH (tmpl_parms)),
+ tmpl, TREE_VEC_LENGTH (tmpl_parms));
return false;
}
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 15:23 gcc/cp/pt.c: use ngettext() when needed Marco Poletti
@ 2010-02-17 15:25 ` Marco Poletti
2010-02-17 17:06 ` Gabriel Dos Reis
1 sibling, 0 replies; 30+ messages in thread
From: Marco Poletti @ 2010-02-17 15:25 UTC (permalink / raw)
To: gcc-patches
2010/2/17 Marco Poletti <poletti.marco@gmail.com>:
> In the file pt.c, there were translatable strings like "redeclared
> with %d template parameter(s)" that are hard to translate.
> Instead, it should use the ngettext() function to allow more flexible
> translations.
> I've added two functions inform_translated() and error_translated() to
> diagnostic.c, that are called by pt.c.
> This is my second patch to GCC, I could have done something wrong.
> Critics are very appreciated.
>
> Changelog for gcc/cp/:
> * pt.c (redeclare_class_template): Use inform_translated and
> error_translated
>
> Changelog for gcc/
> * diagnostic.h (inform_translated): Declare.
> (error_translated): Declare.
> * diagnostic.c (inform_translated): New function.
> (error_translated): New function.
>
> Patch:
>
> Index: gcc/diagnostic.c
> ===================================================================
> --- gcc/diagnostic.c (revisione 156824)
> +++ gcc/diagnostic.c (copia locale)
> @@ -519,6 +519,20 @@ inform (location_t location, const char
> va_end (ap);
> }
>
> +/* An informative note at LOCATION. Use this for additional details
> on an error
> + message. The message is already translated. */
> +void
> +inform_translated (location_t location, const char *gmsgid, ...)
> +{
> + diagnostic_info diagnostic;
> + va_list ap;
> +
> + va_start (ap, gmsgid);
> + diagnostic_set_info_translated (&diagnostic, gmsgid, &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 +627,21 @@ 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. The message is already translated. */
> +void
> +error_translated (const char *gmsgid, ...)
> +{
> + diagnostic_info diagnostic;
> + va_list ap;
> +
> + va_start (ap, gmsgid);
> + diagnostic_set_info_translated (&diagnostic, gmsgid, &ap, input_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 156824)
> +++ gcc/toplev.h (copia locale)
> @@ -63,6 +63,7 @@ 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_translated (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
> 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 +73,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_translated (location_t, const char *, ...)
> +ATTRIBUTE_GCC_DIAG(2,3);
> 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 156824)
> +++ gcc/cp/pt.c (copia locale)
> @@ -4614,10 +4614,15 @@ 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_translated (ngettext ("redeclared with %d template parameter",
> + "redeclared with %d template parameters",
> + TREE_VEC_LENGTH (parms)),
> + TREE_VEC_LENGTH (parms));
> + inform_translated (input_location,
> + ngettext("previous declaration %q+D used %d
> template parameter",
> + "previous declaration %q+D used %d
> template parameters",
> + TREE_VEC_LENGTH (tmpl_parms)),
> + tmpl, TREE_VEC_LENGTH (tmpl_parms));
> return false;
> }
>
Sorry, wrong Changelog, the correct one is:
Changelog for gcc/cp/:
* pt.c (redeclare_class_template): Use inform_translated and
error_translated
Changelog for gcc/
* toplev.h (inform_translated): Declare.
(error_translated): Declare.
* diagnostic.c (inform_translated): New function.
(error_translated): New function.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 15:23 gcc/cp/pt.c: use ngettext() when needed Marco Poletti
2010-02-17 15:25 ` Marco Poletti
@ 2010-02-17 17:06 ` Gabriel Dos Reis
2010-02-17 18:02 ` Marco Poletti
2010-02-17 18:29 ` Paolo Bonzini
1 sibling, 2 replies; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-02-17 17:06 UTC (permalink / raw)
To: Marco Poletti; +Cc: gcc-patches
On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti <poletti.marco@gmail.com> wrote:
> In the file pt.c, there were translatable strings like "redeclared
> with %d template parameter(s)" that are hard to translate.
> Instead, it should use the ngettext() function to allow more flexible
> translations.
> I've added two functions inform_translated() and error_translated() to
> diagnostic.c, that are called by pt.c.
> This is my second patch to GCC, I could have done something wrong.
> Critics are very appreciated.
I'm uncomfortable with adding these two functions.
It is possible to just call a preprocessor ngettext() first and give the
result to error() or inform()?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 17:06 ` Gabriel Dos Reis
@ 2010-02-17 18:02 ` Marco Poletti
2010-02-17 18:29 ` Paolo Bonzini
1 sibling, 0 replies; 30+ messages in thread
From: Marco Poletti @ 2010-02-17 18:02 UTC (permalink / raw)
To: gdr; +Cc: gcc-patches
2010/2/17 Gabriel Dos Reis <dosreis@gmail.com>:
> On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti <poletti.marco@gmail.com> wrote:
>> In the file pt.c, there were translatable strings like "redeclared
>> with %d template parameter(s)" that are hard to translate.
>> Instead, it should use the ngettext() function to allow more flexible
>> translations.
>> I've added two functions inform_translated() and error_translated() to
>> diagnostic.c, that are called by pt.c.
>> This is my second patch to GCC, I could have done something wrong.
>> Critics are very appreciated.
>
> I'm uncomfortable with adding these two functions.
> It is possible to just call a preprocessor ngettext() first and give the
> result to error() or inform()?
>
Can you explain better? What do you mean with "preprocessor ngettext()"?
If you mean implementing ngettext() with the preprocessor, it's too
complicated IMHO.
However, you should not pass the ngettext() output to error() or
inform() because they call diagnostic_set_info() that would attempt to
translate the string again.
A similar solution is already used in collect2.c BTW.
Marco Poletti
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 17:06 ` Gabriel Dos Reis
2010-02-17 18:02 ` Marco Poletti
@ 2010-02-17 18:29 ` Paolo Bonzini
2010-02-17 20:07 ` Marco Poletti
2010-02-17 21:26 ` Joseph S. Myers
1 sibling, 2 replies; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-17 18:29 UTC (permalink / raw)
To: gdr; +Cc: Gabriel Dos Reis, Marco Poletti, gcc-patches
On 02/17/2010 06:06 PM, Gabriel Dos Reis wrote:
> On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti <poletti.marco@gmail.com> wrote:
>> In the file pt.c, there were translatable strings like "redeclared
>> with %d template parameter(s)" that are hard to translate. Instead,
>> it should use the ngettext() function to allow more flexible
>> translations. I've added two functions inform_translated() and
>> error_translated() to diagnostic.c, that are called by pt.c. This
>> is my second patch to GCC, I could have done something wrong.
>> Critics are very appreciated.
>
> I'm uncomfortable with adding these two functions. It is possible to
> just call a preprocessor ngettext() first and give the result to
> error() or inform()?
Marco, why don't you instead add warning_n/inform_n/error_n, like
error_n (TREE_VEC_LENGTH (parms),
"redeclared with %d template parameter",
"redeclared with %d template parameters",
TREE_VEC_LENGTH (parms));
(compared to ngettext I'm moving the number argument before the strings,
to make sure it's not confused with the first positional parameter of
printf). This can be taught to exgettext with something like this:
Index: exgettext
===================================================================
--- exgettext (revision 156795)
+++ exgettext (working copy)
@@ -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) {
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 18:29 ` Paolo Bonzini
@ 2010-02-17 20:07 ` Marco Poletti
2010-02-17 21:26 ` Joseph S. Myers
1 sibling, 0 replies; 30+ messages in thread
From: Marco Poletti @ 2010-02-17 20:07 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: gdr, Gabriel Dos Reis, gcc-patches
2010/2/17 Paolo Bonzini <bonzini@gnu.org>:
> On 02/17/2010 06:06 PM, Gabriel Dos Reis wrote:
>>
>> On Wed, Feb 17, 2010 at 9:23 AM, Marco Poletti <poletti.marco@gmail.com>
>> wrote:
>>>
>>> In the file pt.c, there were translatable strings like "redeclared
>>> with %d template parameter(s)" that are hard to translate. Instead,
>>> it should use the ngettext() function to allow more flexible
>>> translations. I've added two functions inform_translated() and
>>> error_translated() to diagnostic.c, that are called by pt.c. This
>>> is my second patch to GCC, I could have done something wrong.
>>> Critics are very appreciated.
>>
>> I'm uncomfortable with adding these two functions. It is possible to
>> just call a preprocessor ngettext() first and give the result to
>> error() or inform()?
>
> Marco, why don't you instead add warning_n/inform_n/error_n, like
>
> error_n (TREE_VEC_LENGTH (parms),
> "redeclared with %d template parameter",
> "redeclared with %d template parameters",
> TREE_VEC_LENGTH (parms));
>
> (compared to ngettext I'm moving the number argument before the strings, to
> make sure it's not confused with the first positional parameter of printf).
By "adding" you mean implementing as functions, no macros involved, right?
This would be ok IMHO.
How do you imagine the prototype?
Something like
error_n(int,const char*,const char*, ...)
or
error_n(int,const char*,const char*, int)
? (I prefer the first one, more general)
> This can be taught to exgettext with something like this:
>
> Index: exgettext
> ===================================================================
> --- exgettext (revision 156795)
> +++ exgettext (working copy)
> @@ -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) {
>
> Paolo
>
If you say so :-)
I don't understand this code.
Marco
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 18:29 ` Paolo Bonzini
2010-02-17 20:07 ` Marco Poletti
@ 2010-02-17 21:26 ` Joseph S. Myers
2010-02-17 21:32 ` Marco Poletti
1 sibling, 1 reply; 30+ messages in thread
From: Joseph S. Myers @ 2010-02-17 21:26 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: gdr, Gabriel Dos Reis, Marco Poletti, gcc-patches
On Wed, 17 Feb 2010, Paolo Bonzini wrote:
> Marco, why don't you instead add warning_n/inform_n/error_n, like
>
> error_n (TREE_VEC_LENGTH (parms),
> "redeclared with %d template parameter",
> "redeclared with %d template parameters",
> TREE_VEC_LENGTH (parms));
>
> (compared to ngettext I'm moving the number argument before the strings, to
> make sure it's not confused with the first positional parameter of printf).
> This can be taught to exgettext with something like this:
If you add new functions like that, they should have a leading location_t
argument for an explicit location, rather than emulating the legacy
functions without an explicit location. (It's OK when converting a call
to use such a new function just to put input_location for the location
rather than trying to work out a more precise location for the error.)
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 21:26 ` Joseph S. Myers
@ 2010-02-17 21:32 ` Marco Poletti
2010-02-17 23:23 ` Paolo Bonzini
0 siblings, 1 reply; 30+ messages in thread
From: Marco Poletti @ 2010-02-17 21:32 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: Paolo Bonzini, gdr, Gabriel Dos Reis, gcc-patches
2010/2/17 Joseph S. Myers <joseph@codesourcery.com>:
> On Wed, 17 Feb 2010, Paolo Bonzini wrote:
>
>> Marco, why don't you instead add warning_n/inform_n/error_n, like
>>
>> error_n (TREE_VEC_LENGTH (parms),
>> "redeclared with %d template parameter",
>> "redeclared with %d template parameters",
>> TREE_VEC_LENGTH (parms));
>>
>> (compared to ngettext I'm moving the number argument before the strings, to
>> make sure it's not confused with the first positional parameter of printf).
>> This can be taught to exgettext with something like this:
>
> If you add new functions like that, they should have a leading location_t
> argument for an explicit location, rather than emulating the legacy
> functions without an explicit location. (It's OK when converting a call
> to use such a new function just to put input_location for the location
> rather than trying to work out a more precise location for the error.)
>
So it would be something like
error_n(location_t,int,const char*,const char*, ...)
?
Does the exgettext patch need some changes to reflect this change?
> --
> Joseph S. Myers
> joseph@codesourcery.com
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 21:32 ` Marco Poletti
@ 2010-02-17 23:23 ` Paolo Bonzini
2010-02-18 14:33 ` Marco Poletti
0 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-17 23:23 UTC (permalink / raw)
To: Marco Poletti; +Cc: Joseph S. Myers, gdr, Gabriel Dos Reis, gcc-patches
On Wed, Feb 17, 2010 at 22:32, Marco Poletti <poletti.marco@gmail.com> wrote:
> 2010/2/17 Joseph S. Myers <joseph@codesourcery.com>:
>> On Wed, 17 Feb 2010, Paolo Bonzini wrote:
>>
>>> Marco, why don't you instead add warning_n/inform_n/error_n, like
>>>
>>> error_n (TREE_VEC_LENGTH (parms),
>>> "redeclared with %d template parameter",
>>> "redeclared with %d template parameters",
>>> TREE_VEC_LENGTH (parms));
>>>
>>> (compared to ngettext I'm moving the number argument before the strings, to
>>> make sure it's not confused with the first positional parameter of printf).
>>> This can be taught to exgettext with something like this:
>>
>> If you add new functions like that, they should have a leading location_t
>> argument for an explicit location, rather than emulating the legacy
>> functions without an explicit location. (It's OK when converting a call
>> to use such a new function just to put input_location for the location
>> rather than trying to work out a more precise location for the error.)
>>
>
> So it would be something like
>
> error_n(location_t,int,const char*,const char*, ...)
>
> ?
Yes, with ...
Thanks Joseph for pointing out location_t. Also for warning_n you'd
need an extra argument for the option name, but that one function can
come later.
> Does the exgettext patch need some changes to reflect this change?
No.
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-17 23:23 ` Paolo Bonzini
@ 2010-02-18 14:33 ` Marco Poletti
2010-02-18 14:40 ` Jakub Jelinek
0 siblings, 1 reply; 30+ messages in thread
From: Marco Poletti @ 2010-02-18 14:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Joseph S. Myers, gdr, Gabriel Dos Reis, gcc-patches
>> [...]
>> So it would be something like
>>
>> error_n(location_t,int,const char*,const char*, ...)
>>
>> ?
>
> Yes, with ...
>
> Thanks Joseph for pointing out location_t. Also for warning_n you'd
> need an extra argument for the option name, but that one function can
> come later.
>
>> Does the exgettext patch need some changes to reflect this change?
>
> No.
>
> Paolo
>
I attach an updated patch, that follows Paolo's advice (I hope!).
Please comment on this, especially on the ATTRIBUTE_GCC_DIAGs because
I tried to understand their meaning by other uses in the file and they
could be completely wrong.
Only thing I know is that they compile successfully (make bootstrap)
both with and without --disable-nls.
Marco
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. The message is already translated. */
+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. The message is already translated. */
+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) {
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-18 14:33 ` Marco Poletti
@ 2010-02-18 14:40 ` Jakub Jelinek
2010-02-18 14:49 ` Marco Poletti
0 siblings, 1 reply; 30+ messages in thread
From: Jakub Jelinek @ 2010-02-18 14:40 UTC (permalink / raw)
To: Marco Poletti
Cc: Paolo Bonzini, Joseph S. Myers, gdr, Gabriel Dos Reis, gcc-patches
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
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-18 14:40 ` Jakub Jelinek
@ 2010-02-18 14:49 ` Marco Poletti
2010-02-22 9:38 ` Marco Poletti
0 siblings, 1 reply; 30+ messages in thread
From: Marco Poletti @ 2010-02-18 14:49 UTC (permalink / raw)
To: Jakub Jelinek
Cc: Paolo Bonzini, Joseph S. Myers, gdr, Gabriel Dos Reis, gcc-patches
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) {
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-18 14:49 ` Marco Poletti
@ 2010-02-22 9:38 ` Marco Poletti
2010-02-24 6:47 ` Shujing Zhao
0 siblings, 1 reply; 30+ messages in thread
From: Marco Poletti @ 2010-02-22 9:38 UTC (permalink / raw)
To: Jakub Jelinek
Cc: Paolo Bonzini, Joseph S. Myers, gdr, Gabriel Dos Reis, gcc-patches
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
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-22 9:38 ` Marco Poletti
@ 2010-02-24 6:47 ` Shujing Zhao
2010-02-24 6:57 ` Paolo Bonzini
2010-02-26 7:30 ` Gabriel Dos Reis
0 siblings, 2 replies; 30+ messages in thread
From: Shujing Zhao @ 2010-02-24 6:47 UTC (permalink / raw)
To: Marco Poletti
Cc: Jakub Jelinek, Paolo Bonzini, Joseph S. Myers, gdr,
Gabriel Dos Reis, gcc-patches, Paolo Carlini
On 02/22/2010 05:25 PM, Marco Poletti wrote:
>> @@ -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) {
>>
>
Marco, xgettext can't accept the --flag argument that have more than one
argnums. It will have the argnums like 2,3 if the above code added.
How about to only use the conditional expression like
error (TREE_VEC_LENGTH (parms) > 1
? G_("redeclared with %d template parameters")
: G_("redeclared with %d template parameter"),
TREE_VEC_LENGTH (parms));
it changed less to fix this problem.
Pearly
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-24 6:47 ` Shujing Zhao
@ 2010-02-24 6:57 ` Paolo Bonzini
2010-02-24 8:55 ` Shujing Zhao
2010-02-26 7:30 ` Gabriel Dos Reis
1 sibling, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-24 6:57 UTC (permalink / raw)
To: Shujing Zhao
Cc: Marco Poletti, Jakub Jelinek, Joseph S. Myers, gdr,
Gabriel Dos Reis, gcc-patches, Paolo Carlini
> Marco, xgettext can't accept the --flag argument that have more than one
> argnums. It will have the argnums like 2,3 if the above code added.
Not true:
If KEYWORDSPEC is
of the form `ID:ARGNUM1,ARGNUM2', `xgettext' looks for strings in
the ARGNUM1st argument and in the ARGNUM2nd argument of the call,
and treats them as singular/plural variants for a message with
plural handling.
> How about to only use the conditional expression like
>
> error (TREE_VEC_LENGTH (parms) > 1
> ? G_("redeclared with %d template parameters")
> : G_("redeclared with %d template parameter"),
> TREE_VEC_LENGTH (parms));
>
> it changed less to fix this problem.
It wouldn't work for all Slavic and Baltic languages (and a few others),
where you have multiple plural forms.
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-24 6:57 ` Paolo Bonzini
@ 2010-02-24 8:55 ` Shujing Zhao
2010-02-24 10:22 ` Paolo Bonzini
0 siblings, 1 reply; 30+ messages in thread
From: Shujing Zhao @ 2010-02-24 8:55 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marco Poletti, Jakub Jelinek, Joseph S. Myers, gdr,
Gabriel Dos Reis, gcc-patches, Paolo Carlini
On 02/24/2010 02:47 PM, Paolo Bonzini wrote:
>
>> Marco, xgettext can't accept the --flag argument that have more than one
>> argnums. It will have the argnums like 2,3 if the above code added.
>
> Not true:
>
> If KEYWORDSPEC is
> of the form `ID:ARGNUM1,ARGNUM2', `xgettext' looks for strings in
> the ARGNUM1st argument and in the ARGNUM2nd argument of the call,
> and treats them as singular/plural variants for a message with
> plural handling.
>
Yes, --keyword is assigned KEYWORDSPEC, but
'--flag=word:arg:flagâ
Specifies additional flags for strings occurring as part of the argth
argument of the function word.
I think the --keyword=error_n:3,4 should the following flag
--flag=error_n:3:gcc-internal-format
--flag=error_n:4:gcc-internal-format
but not --flag=error_n:3,4:gcc-internal-format
So the change for exgettext would be
Index: po/exgettext
===================================================================
--- po/exgettext ï¼ä¿®è®¢ç 157027ï¼
+++ po/exgettext ï¼å·¥ä½æ·è´ï¼
@@ -113,9 +113,14 @@ function keyword_option(line) {
format="c-format"
if (n == 1) { keyword = "--keyword=" name }
- else { keyword = "--keyword=" name ":" n }
+ else {
+ keyword = "--keyword=" name ":" n
+ if (name ~ /_n$/)
+ keyword = keyword "," (n + 1)}
if (format) {
keyword=keyword "\n--flag=" name ":" n ":" format
+ if (name ~ /_n$/)
+ keyword = keyword "\n--flag=" name ":" (n + 1) ":" format
}
if (! keyword_seen[name]) {
Pearly
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-24 8:55 ` Shujing Zhao
@ 2010-02-24 10:22 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-24 10:22 UTC (permalink / raw)
To: Shujing Zhao
Cc: Marco Poletti, Jakub Jelinek, Joseph S. Myers, gdr,
Gabriel Dos Reis, gcc-patches, Paolo Carlini
On 02/24/2010 08:53 AM, Shujing Zhao wrote:
>
> So the change for exgettext would be
> Index: po/exgettext
> ===================================================================
> --- po/exgettext ï¼ä¿®è®¢ç 157027ï¼
> +++ po/exgettext ï¼å·¥ä½æ·è´ï¼
> @@ -113,9 +113,14 @@ function keyword_option(line) {
> format="c-format"
>
> if (n == 1) { keyword = "--keyword=" name }
> - else { keyword = "--keyword=" name ":" n }
> + else {
> + keyword = "--keyword=" name ":" n
> + if (name ~ /_n$/)
> + keyword = keyword "," (n + 1)}
Ah, I see. Yes, this is correct except for a little formatting problem
in the closing brace here.
> if (format) {
> keyword=keyword "\n--flag=" name ":" n ":" format
> + if (name ~ /_n$/)
> + keyword = keyword "\n--flag=" name ":" (n + 1) ":" format
> }
>
> if (! keyword_seen[name]) {
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-24 6:47 ` Shujing Zhao
2010-02-24 6:57 ` Paolo Bonzini
@ 2010-02-26 7:30 ` Gabriel Dos Reis
2010-02-26 7:31 ` Marco Poletti
1 sibling, 1 reply; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-02-26 7:30 UTC (permalink / raw)
To: Shujing Zhao
Cc: Marco Poletti, Jakub Jelinek, Paolo Bonzini, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Tue, Feb 23, 2010 at 10:07 PM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
> On 02/22/2010 05:25 PM, Marco Poletti wrote:
>>>
>>> @@ -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) {
>>>
>>
> Marco, xgettext can't accept the --flag argument that have more than one
> argnums. It will have the argnums like 2,3 if the above code added.
>
> How about to only use the conditional expression like
>
> error (TREE_VEC_LENGTH (parms) > 1
> ? G_("redeclared with %d template parameters")
> : G_("redeclared with %d template parameter"),
> TREE_VEC_LENGTH (parms));
>
> it changed less to fix this problem.
this is close to what I originally had in mind
>
> Pearly
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 7:30 ` Gabriel Dos Reis
@ 2010-02-26 7:31 ` Marco Poletti
2010-02-26 9:32 ` Gabriel Dos Reis
0 siblings, 1 reply; 30+ messages in thread
From: Marco Poletti @ 2010-02-26 7:31 UTC (permalink / raw)
To: Gabriel Dos Reis
Cc: Shujing Zhao, Jakub Jelinek, Paolo Bonzini, Joseph S. Myers,
gcc-patches, Paolo Carlini
2010/2/26 Gabriel Dos Reis <gdr@integrable-solutions.net>:
> On Tue, Feb 23, 2010 at 10:07 PM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
>> On 02/22/2010 05:25 PM, Marco Poletti wrote:
>>>>
>>>> @@ -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) {
>>>>
>>>
>> Marco, xgettext can't accept the --flag argument that have more than one
>> argnums. It will have the argnums like 2,3 if the above code added.
>>
>> How about to only use the conditional expression like
>>
>> error (TREE_VEC_LENGTH (parms) > 1
>> ? G_("redeclared with %d template parameters")
>> : G_("redeclared with %d template parameter"),
>> TREE_VEC_LENGTH (parms));
>>
>> it changed less to fix this problem.
>
> this is close to what I originally had in mind
>
>>
>> Pearly
>>
>
So, can this be committed?
Marco
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 7:31 ` Marco Poletti
@ 2010-02-26 9:32 ` Gabriel Dos Reis
2010-02-26 9:43 ` Paolo Bonzini
0 siblings, 1 reply; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-02-26 9:32 UTC (permalink / raw)
To: Marco Poletti
Cc: Shujing Zhao, Jakub Jelinek, Paolo Bonzini, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Fri, Feb 26, 2010 at 1:13 AM, Marco Poletti <poletti.marco@gmail.com> wrote:
> 2010/2/26 Gabriel Dos Reis <gdr@integrable-solutions.net>:
>> On Tue, Feb 23, 2010 at 10:07 PM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
>>> On 02/22/2010 05:25 PM, Marco Poletti wrote:
>>>>>
>>>>> @@ -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) {
>>>>>
>>>>
>>> Marco, xgettext can't accept the --flag argument that have more than one
>>> argnums. It will have the argnums like 2,3 if the above code added.
>>>
>>> How about to only use the conditional expression like
>>>
>>> error (TREE_VEC_LENGTH (parms) > 1
>>> ? G_("redeclared with %d template parameters")
>>> : G_("redeclared with %d template parameter"),
>>> TREE_VEC_LENGTH (parms));
>>>
>>> it changed less to fix this problem.
>>
>> this is close to what I originally had in mind
>>
>>>
>>> Pearly
>>>
>>
>
> So, can this be committed?
by "this", do you mean the suggestion of error() with the G_
translation?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 9:32 ` Gabriel Dos Reis
@ 2010-02-26 9:43 ` Paolo Bonzini
2010-02-26 9:56 ` Gabriel Dos Reis
0 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-26 9:43 UTC (permalink / raw)
To: Gabriel Dos Reis
Cc: Marco Poletti, Shujing Zhao, Jakub Jelinek, Joseph S. Myers,
gcc-patches, Paolo Carlini
On 02/26/2010 08:31 AM, Gabriel Dos Reis wrote:
>> > So, can this be committed?
>
> by "this", do you mean the suggestion of error() with the G_
> translation?
No, that (as I already said upthread) will not work for Baltic and
Slavic languages. A Czech example:
1 kandidát
2-3-4 kandidáti
5+ kandidátů
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 9:43 ` Paolo Bonzini
@ 2010-02-26 9:56 ` Gabriel Dos Reis
2010-02-26 10:03 ` Jakub Jelinek
0 siblings, 1 reply; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-02-26 9:56 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Marco Poletti, Shujing Zhao, Jakub Jelinek, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Fri, Feb 26, 2010 at 3:26 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 02/26/2010 08:31 AM, Gabriel Dos Reis wrote:
>>>
>>> > So, can this be committed?
>>
>> by "this", do you mean the suggestion of error() with the G_
>> translation?
>
> No, that (as I already said upthread) will not work for Baltic and Slavic
> languages. A Czech example:
>
> 1 kandidát
> 2-3-4 kandidáti
> 5+ kandidátů
>
> Paolo
>
yes, but if you want me to review a new version of your patch
based on feedbacks, don't hesitate to be more specific about
what "this" refers to.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 9:56 ` Gabriel Dos Reis
@ 2010-02-26 10:03 ` Jakub Jelinek
2010-02-26 10:04 ` Gabriel Dos Reis
0 siblings, 1 reply; 30+ messages in thread
From: Jakub Jelinek @ 2010-02-26 10:03 UTC (permalink / raw)
To: Gabriel Dos Reis
Cc: Paolo Bonzini, Marco Poletti, Shujing Zhao, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Fri, Feb 26, 2010 at 03:32:27AM -0600, Gabriel Dos Reis wrote:
> > No, that (as I already said upthread) will not work for Baltic and Slavic
> > languages. Â A Czech example:
> >
> >  1 kandidát
> >  2-3-4 kandidáti
> >  5+ kandidátů
> >
> > Paolo
> >
>
> yes, but if you want me to review a new version of your patch
> based on feedbacks, don't hesitate to be more specific about
> what "this" refers to.
http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00719.html
with
http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00961.html
changes for exgettext instead of the original one.
Jakub
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 10:03 ` Jakub Jelinek
@ 2010-02-26 10:04 ` Gabriel Dos Reis
2010-02-26 10:09 ` Shujing Zhao
0 siblings, 1 reply; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-02-26 10:04 UTC (permalink / raw)
To: Jakub Jelinek
Cc: Paolo Bonzini, Marco Poletti, Shujing Zhao, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Fri, Feb 26, 2010 at 3:39 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Feb 26, 2010 at 03:32:27AM -0600, Gabriel Dos Reis wrote:
>> > No, that (as I already said upthread) will not work for Baltic and Slavic
>> > languages. A Czech example:
>> >
>> > 1 kandidát
>> > 2-3-4 kandidáti
>> > 5+ kandidátů
>> >
>> > Paolo
>> >
>>
>> yes, but if you want me to review a new version of your patch
>> based on feedbacks, don't hesitate to be more specific about
>> what "this" refers to.
>
> http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00719.html
> with
> http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00961.html
> changes for exgettext instead of the original one.
>
> Jakub
>
The patch is OK. Thanks.
-- Gaby
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 10:04 ` Gabriel Dos Reis
@ 2010-02-26 10:09 ` Shujing Zhao
2010-02-26 10:42 ` Paolo Bonzini
0 siblings, 1 reply; 30+ messages in thread
From: Shujing Zhao @ 2010-02-26 10:09 UTC (permalink / raw)
To: Gabriel Dos Reis
Cc: Jakub Jelinek, Paolo Bonzini, Marco Poletti, Joseph S. Myers,
gcc-patches, Paolo Carlini
On 02/26/2010 05:43 PM, Gabriel Dos Reis wrote:
> On Fri, Feb 26, 2010 at 3:39 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Fri, Feb 26, 2010 at 03:32:27AM -0600, Gabriel Dos Reis wrote:
>>>> No, that (as I already said upthread) will not work for Baltic and Slavic
>>>> languages. A Czech example:
>>>>
>>>> 1 kandidát
>>>> 2-3-4 kandidáti
>>>> 5+ kandidátů
>>>>
>>>> Paolo
>>>>
>>> yes, but if you want me to review a new version of your patch
>>> based on feedbacks, don't hesitate to be more specific about
>>> what "this" refers to.
>> http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00719.html
>> with
>> http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00961.html
>> changes for exgettext instead of the original one.
>>
>> Jakub
>>
>
> The patch is OK. Thanks.
I viewed the new generated gcc.pot by this patch, the changed parts are the
following:
#: cp/pt.c:4667
#, gcc-internal-format
msgid "redeclared with %d template parameter"
msgid_plural "redeclared with %d template parameters"
msgstr[0] ""
msgstr[1] ""
#: cp/pt.c:4671
#, gcc-internal-format
msgid "previous declaration %q+D used %d template parameter"
msgid_plural "previous declaration %q+D used %d template parameters"
msgstr[0] ""
msgstr[1] ""
Just be curious, how the msgstr will be set at the above example Paolo indicated.
Thanks
Pearly
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 10:09 ` Shujing Zhao
@ 2010-02-26 10:42 ` Paolo Bonzini
2010-02-26 10:43 ` Jakub Jelinek
0 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2010-02-26 10:42 UTC (permalink / raw)
To: Shujing Zhao
Cc: Gabriel Dos Reis, Jakub Jelinek, Marco Poletti, Joseph S. Myers,
gcc-patches, Paolo Carlini
> I viewed the new generated gcc.pot by this patch, the changed parts are
> the following:
>
> #: cp/pt.c:4667
> #, gcc-internal-format
> msgid "redeclared with %d template parameter"
> msgid_plural "redeclared with %d template parameters"
> msgstr[0] ""
> msgstr[1] ""
>
> #: cp/pt.c:4671
> #, gcc-internal-format
> msgid "previous declaration %q+D used %d template parameter"
> msgid_plural "previous declaration %q+D used %d template parameters"
> msgstr[0] ""
> msgstr[1] ""
>
> Just be curious, how the msgstr will be set at the above example Paolo
> indicated.
Czech translators have to add a "msgstr[2]" line and add this at the top
of the .po file
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 10:42 ` Paolo Bonzini
@ 2010-02-26 10:43 ` Jakub Jelinek
2010-03-01 10:00 ` Shujing Zhao
0 siblings, 1 reply; 30+ messages in thread
From: Jakub Jelinek @ 2010-02-26 10:43 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Shujing Zhao, Gabriel Dos Reis, Jakub Jelinek, Marco Poletti,
Joseph S. Myers, gcc-patches, Paolo Carlini
On Fri, Feb 26, 2010 at 11:04:19AM +0100, Paolo Bonzini wrote:
>
> >I viewed the new generated gcc.pot by this patch, the changed parts are
> >the following:
> >
> >#: cp/pt.c:4667
> >#, gcc-internal-format
> >msgid "redeclared with %d template parameter"
> >msgid_plural "redeclared with %d template parameters"
> >msgstr[0] ""
> >msgstr[1] ""
> >
> >#: cp/pt.c:4671
> >#, gcc-internal-format
> >msgid "previous declaration %q+D used %d template parameter"
> >msgid_plural "previous declaration %q+D used %d template parameters"
> >msgstr[0] ""
> >msgstr[1] ""
> >
> >Just be curious, how the msgstr will be set at the above example Paolo
> >indicated.
>
> Czech translators have to add a "msgstr[2]" line and add this at the
> top of the .po file
>
> "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
I believe it is still
Plural-Forms: nplurals=3; plural=n%100/10==1 ? 2 : n%10==1 ? 0 : (n+9)%10>3 ? 2 : 1;
for Czech, anyway, it doesn't matter here much and it is up to the
translators.
Jakub
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-02-26 10:43 ` Jakub Jelinek
@ 2010-03-01 10:00 ` Shujing Zhao
2010-03-01 10:16 ` Shujing Zhao
0 siblings, 1 reply; 30+ messages in thread
From: Shujing Zhao @ 2010-03-01 10:00 UTC (permalink / raw)
To: Jakub Jelinek
Cc: Paolo Bonzini, Gabriel Dos Reis, Marco Poletti, Joseph S. Myers,
gcc-patches, Paolo Carlini
[-- Attachment #1: Type: text/plain, Size: 1140 bytes --]
On 02/26/2010 06:08 PM, Jakub Jelinek wrote:
> On Fri, Feb 26, 2010 at 11:04:19AM +0100, Paolo Bonzini wrote:
>>> I viewed the new generated gcc.pot by this patch, the changed parts are
>>> the following:
>>>
>>> #: cp/pt.c:4667
>>> #, gcc-internal-format
>>> msgid "redeclared with %d template parameter"
>>> msgid_plural "redeclared with %d template parameters"
>>> msgstr[0] ""
>>> msgstr[1] ""
>>>
>>> #: cp/pt.c:4671
>>> #, gcc-internal-format
>>> msgid "previous declaration %q+D used %d template parameter"
>>> msgid_plural "previous declaration %q+D used %d template parameters"
>>> msgstr[0] ""
>>> msgstr[1] ""
>>>
>>> Just be curious, how the msgstr will be set at the above example Paolo
>>> indicated.
>> Czech translators have to add a "msgstr[2]" line and add this at the
>> top of the .po file
>>
>> "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
>
> I believe it is still
> Plural-Forms: nplurals=3; plural=n%100/10==1 ? 2 : n%10==1 ? 0 : (n+9)%10>3 ? 2 : 1;
> for Czech, anyway, it doesn't matter here much and it is up to the
> translators.
>
> Jakub
>
Tested and committed revision 157134.
[-- Attachment #2: a.diff --]
[-- Type: text/x-patch, Size: 5136 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (revision 157133)
+++ ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2010-03-01 Marco Poletti <poletti.marco@gmail.com>
+
+ * toplev.h (inform_n, error_n): Declare.
+ * diagnostic.c (inform_n, error_n): New function.
+
2010-03-01 Jakub Jelinek <jakub@redhat.com>
* cfgexpand.c (expand_used_vars): If an artificial non-ignored var
Index: cp/ChangeLog
===================================================================
--- cp/ChangeLog (revision 157133)
+++ cp/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2010-03-01 Marco Poletti <poletti.marco@gmail.com>
+
+ * pt.c (redeclare_class_template): Use error_n and inform_n.
+
2010-02-27 Mark Mitchell <mark@codesourcery.com>
PR c++/42748
Index: po/ChangeLog
===================================================================
--- po/ChangeLog (revision 157133)
+++ po/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2010-03-01 Shujing Zhao <pearly.zhao@oracle.com>
+
+ * exgettext: Handle the functions that end with _n.
+
2010-02-24 Joseph Myers <joseph@codesourcery.com>
* zh_CN.po: Update.
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 157133)
+++ diagnostic.c (working copy)
@@ -520,6 +520,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. */
@@ -615,6 +632,23 @@ error (const char *gmsgid, ...)
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
error_at (location_t loc, const char *gmsgid, ...)
Index: toplev.h
===================================================================
--- toplev.h (revision 157133)
+++ toplev.h (working copy)
@@ -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: cp/pt.c
===================================================================
--- cp/pt.c (revision 157133)
+++ cp/pt.c (working copy)
@@ -4661,10 +4661,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;
}
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-03-01 10:00 ` Shujing Zhao
@ 2010-03-01 10:16 ` Shujing Zhao
2010-03-01 15:12 ` Gabriel Dos Reis
0 siblings, 1 reply; 30+ messages in thread
From: Shujing Zhao @ 2010-03-01 10:16 UTC (permalink / raw)
To: Jakub Jelinek
Cc: Paolo Bonzini, Gabriel Dos Reis, Marco Poletti, Joseph S. Myers,
gcc-patches, Paolo Carlini
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
On 03/01/2010 05:58 PM, Shujing Zhao wrote:
>
> Tested and committed revision 157134.
>
Sorry, the last patch is not right. I'd better to attach the revision diff.
Pearly
[-- Attachment #2: a.diff --]
[-- Type: text/x-patch, Size: 5831 bytes --]
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 157133)
+++ diagnostic.c (revision 157134)
@@ -520,6 +520,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. */
@@ -615,6 +632,23 @@ error (const char *gmsgid, ...)
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
error_at (location_t loc, const char *gmsgid, ...)
Index: toplev.h
===================================================================
--- toplev.h (revision 157133)
+++ toplev.h (revision 157134)
@@ -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: ChangeLog
===================================================================
--- ChangeLog (revision 157133)
+++ ChangeLog (revision 157134)
@@ -1,3 +1,8 @@
+2010-03-01 Marco Poletti <poletti.marco@gmail.com>
+
+ * toplev.h (inform_n, error_n): Declare.
+ * diagnostic.c (inform_n, error_n): New function.
+
2010-03-01 Jakub Jelinek <jakub@redhat.com>
* cfgexpand.c (expand_used_vars): If an artificial non-ignored var
Index: cp/ChangeLog
===================================================================
--- cp/ChangeLog (revision 157133)
+++ cp/ChangeLog (revision 157134)
@@ -1,3 +1,7 @@
+2010-03-01 Marco Poletti <poletti.marco@gmail.com>
+
+ * pt.c (redeclare_class_template): Use error_n and inform_n.
+
2010-02-27 Mark Mitchell <mark@codesourcery.com>
PR c++/42748
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 157133)
+++ cp/pt.c (revision 157134)
@@ -4661,10 +4661,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: po/exgettext
===================================================================
--- po/exgettext (revision 157133)
+++ po/exgettext (revision 157134)
@@ -113,9 +113,15 @@ function keyword_option(line) {
format="c-format"
if (n == 1) { keyword = "--keyword=" name }
- else { keyword = "--keyword=" name ":" n }
+ else {
+ keyword = "--keyword=" name ":" n
+ if (name ~ /_n$/)
+ keyword = keyword "," (n + 1)
+ }
if (format) {
keyword=keyword "\n--flag=" name ":" n ":" format
+ if (name ~ /_n$/)
+ keyword = keyword "\n--flag=" name ":" (n + 1) ":" format
}
if (! keyword_seen[name]) {
Index: po/ChangeLog
===================================================================
--- po/ChangeLog (revision 157133)
+++ po/ChangeLog (revision 157134)
@@ -1,3 +1,7 @@
+2010-03-01 Shujing Zhao <pearly.zhao@oracle.com>
+
+ * exgettext: Handle the functions that end with _n.
+
2010-02-24 Joseph Myers <joseph@codesourcery.com>
* zh_CN.po: Update.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: gcc/cp/pt.c: use ngettext() when needed
2010-03-01 10:16 ` Shujing Zhao
@ 2010-03-01 15:12 ` Gabriel Dos Reis
0 siblings, 0 replies; 30+ messages in thread
From: Gabriel Dos Reis @ 2010-03-01 15:12 UTC (permalink / raw)
To: Shujing Zhao
Cc: Jakub Jelinek, Paolo Bonzini, Marco Poletti, Joseph S. Myers,
gcc-patches, Paolo Carlini
On Mon, Mar 1, 2010 at 4:15 AM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
> On 03/01/2010 05:58 PM, Shujing Zhao wrote:
>>
>> Tested and committed revision 157134.
>>
> Sorry, the last patch is not right. I'd better to attach the revision diff.
Thanks.
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2010-03-01 15:12 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-17 15:23 gcc/cp/pt.c: use ngettext() when needed Marco Poletti
2010-02-17 15:25 ` Marco Poletti
2010-02-17 17:06 ` Gabriel Dos Reis
2010-02-17 18:02 ` Marco Poletti
2010-02-17 18:29 ` Paolo Bonzini
2010-02-17 20:07 ` Marco Poletti
2010-02-17 21:26 ` Joseph S. Myers
2010-02-17 21:32 ` Marco Poletti
2010-02-17 23:23 ` Paolo Bonzini
2010-02-18 14:33 ` Marco Poletti
2010-02-18 14:40 ` Jakub Jelinek
2010-02-18 14:49 ` Marco Poletti
2010-02-22 9:38 ` Marco Poletti
2010-02-24 6:47 ` Shujing Zhao
2010-02-24 6:57 ` Paolo Bonzini
2010-02-24 8:55 ` Shujing Zhao
2010-02-24 10:22 ` Paolo Bonzini
2010-02-26 7:30 ` Gabriel Dos Reis
2010-02-26 7:31 ` Marco Poletti
2010-02-26 9:32 ` Gabriel Dos Reis
2010-02-26 9:43 ` Paolo Bonzini
2010-02-26 9:56 ` Gabriel Dos Reis
2010-02-26 10:03 ` Jakub Jelinek
2010-02-26 10:04 ` Gabriel Dos Reis
2010-02-26 10:09 ` Shujing Zhao
2010-02-26 10:42 ` Paolo Bonzini
2010-02-26 10:43 ` Jakub Jelinek
2010-03-01 10:00 ` Shujing Zhao
2010-03-01 10:16 ` Shujing Zhao
2010-03-01 15:12 ` Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).