public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Shujing Zhao <pearly.zhao@oracle.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Paolo Bonzini <bonzini@gnu.org>,
	        Gabriel Dos Reis <gdr@integrable-solutions.net>,
	        Marco Poletti <poletti.marco@gmail.com>,
	        "Joseph S. Myers" <joseph@codesourcery.com>,
	gcc-patches@gcc.gnu.org,
	        Paolo Carlini <paolo.carlini@oracle.com>
Subject: Re: gcc/cp/pt.c: use ngettext() when needed
Date: Mon, 01 Mar 2010 10:00:00 -0000	[thread overview]
Message-ID: <4B8B8FE1.2020502@oracle.com> (raw)
In-Reply-To: <20100226100853.GU2817@tyan-ft48-01.lab.bos.redhat.com>

[-- 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;
     }
 

  reply	other threads:[~2010-03-01 10:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-17 15:23 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 [this message]
2010-03-01 10:16                                           ` Shujing Zhao
2010-03-01 15:12                                             ` Gabriel Dos Reis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B8B8FE1.2020502@oracle.com \
    --to=pearly.zhao@oracle.com \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=paolo.carlini@oracle.com \
    --cc=poletti.marco@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).