This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: gcc/cp/pt.c: use ngettext() when needed
- From: Shujing Zhao <pearly dot zhao at oracle dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Paolo Bonzini <bonzini at gnu dot org>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Marco Poletti <poletti dot marco at gmail dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org, Paolo Carlini <paolo dot carlini at oracle dot com>
- Date: Mon, 01 Mar 2010 18:15:26 +0800
- Subject: Re: gcc/cp/pt.c: use ngettext() when needed
- References: <4B84A60B.5020709@oracle.com> <206fcf961002252308t3883270bpb5d7cd0fd02bf2d@mail.gmail.com> <ae2276fe1002252313w3d435534ge5f22627b898225a@mail.gmail.com> <206fcf961002252331k7f390be1jc96a7025bc34d410@mail.gmail.com> <4B8793BA.8050201@gnu.org> <206fcf961002260132q4aa22a7ep2ff42d145442a971@mail.gmail.com> <20100226093904.GT2817@tyan-ft48-01.lab.bos.redhat.com> <206fcf961002260143v334a4206gc045d9a7b8eb3887@mail.gmail.com> <4B879A27.4010002@oracle.com> <4B879CA3.9080603@gnu.org> <20100226100853.GU2817@tyan-ft48-01.lab.bos.redhat.com> <4B8B8FE1.2020502@oracle.com>
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
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.