From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8249 invoked by alias); 22 Feb 2010 09:25:45 -0000 Received: (qmail 8178 invoked by uid 22791); 22 Feb 2010 09:25:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40 X-Spam-Check-By: sourceware.org Received: from mail-bw0-f214.google.com (HELO mail-bw0-f214.google.com) (209.85.218.214) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Feb 2010 09:25:39 +0000 Received: by bwz6 with SMTP id 6so1587829bwz.16 for ; Mon, 22 Feb 2010 01:25:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.143.139 with SMTP id v11mr1878944bku.98.1266830736825; Mon, 22 Feb 2010 01:25:36 -0800 (PST) In-Reply-To: References: <206fcf961002170906l1bdca005h3833890d35d7db5c@mail.gmail.com> <4B7C3571.60808@gnu.org> <20100218144545.GV2817@tyan-ft48-01.lab.bos.redhat.com> Date: Mon, 22 Feb 2010 09:38:00 -0000 Message-ID: Subject: Re: gcc/cp/pt.c: use ngettext() when needed From: Marco Poletti To: Jakub Jelinek Cc: Paolo Bonzini , "Joseph S. Myers" , gdr@integrable-solutions.net, Gabriel Dos Reis , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-02/txt/msg00863.txt.bz2 2010/2/18 Marco Poletti : > 2010/2/18 Jakub Jelinek : >> On Thu, Feb 18, 2010 at 03:33:34PM +0100, Marco Poletti wrote: >>> --- gcc/diagnostic.c =A0(revisione 156858) >>> +++ gcc/diagnostic.c =A0(copia locale) >>> @@ -519,6 +519,23 @@ inform (location_t location, const char >>> =A0 =A0va_end (ap); >>> =A0} >>> >>> +/* An informative note at LOCATION. =A0Use this for additional details >>> on an error >> >> Too long line. >> >>> + =A0 message. The message is already translated. =A0*/ >> >> The message is not translated, inform_n does the translation. >> >>> +/* A hard error: the code is definitely ill-formed, and an object file >>> + =A0 will not be produced. The message is already translated. =A0*/ >> >> Likewise. >> >> =A0 =A0 =A0 =A0Jakub >> > > @Jakub: > Yes, you're right. Thanks for pointing these out. > > Updated patch: > > Index: gcc/diagnostic.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/diagnostic.c =A0 =A0(revisione 156858) > +++ gcc/diagnostic.c =A0 =A0(copia locale) > @@ -519,6 +519,23 @@ inform (location_t location, const char > =A0 va_end (ap); > =A0} > > +/* An informative note at LOCATION. =A0Use this for additional details o= n an > + =A0 error message. =A0*/ > +void > +inform_n (location_t location, int n, const char *singular_gmsgid, > + =A0 =A0 =A0 =A0 =A0const char *plural_gmsgid, ...) > +{ > + =A0diagnostic_info diagnostic; > + =A0va_list ap; > + > + =A0va_start (ap, plural_gmsgid); > + =A0diagnostic_set_info_translated (&diagnostic, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nget= text (singular_gmsgid, plural_gmsgid, n), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&ap,= location, DK_NOTE); > + =A0report_diagnostic (&diagnostic); > + =A0va_end (ap); > +} > + > =A0/* A warning at INPUT_LOCATION. =A0Use this for code which is correct = according > =A0 =A0to the relevant language specification but is likely to be buggy a= nyway. > =A0 =A0Returns true if the warning was printed, false if it was inhibited= . =A0*/ > @@ -613,6 +630,23 @@ error (const char *gmsgid, ...) > =A0 report_diagnostic (&diagnostic); > =A0 va_end (ap); > =A0} > + > +/* A hard error: the code is definitely ill-formed, and an object file > + =A0 will not be produced. =A0*/ > +void > +error_n (location_t location, int n, const char *singular_gmsgid, > + =A0 =A0 =A0 =A0 const char *plural_gmsgid, ...) > +{ > + =A0diagnostic_info diagnostic; > + =A0va_list ap; > + > + =A0va_start (ap, plural_gmsgid); > + =A0diagnostic_set_info_translated (&diagnostic, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nget= text (singular_gmsgid, plural_gmsgid, n), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&ap,= location, DK_ERROR); > + =A0report_diagnostic (&diagnostic); > + =A0va_end (ap); > +} > > =A0/* Same as ebove, but use location LOC instead of input_location. =A0*/ > =A0void > Index: gcc/toplev.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/toplev.h =A0 =A0 =A0 =A0(revisione 156858) > +++ gcc/toplev.h =A0 =A0 =A0 =A0(copia locale) > @@ -63,6 +63,8 @@ extern bool warning (int, const char *, > =A0extern bool warning_at (location_t, int, const char *, ...) > =A0 =A0 ATTRIBUTE_GCC_DIAG(3,4); > =A0extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); > +extern void error_n (location_t, int, const char *, const char *, ...) > + =A0 =A0ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5); > =A0extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIA= G(2,3); > =A0extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) > =A0 =A0 =A0ATTRIBUTE_NORETURN; > @@ -72,6 +74,8 @@ extern bool pedwarn (location_t, int, co > =A0extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DI= AG(2,3); > =A0extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); > =A0extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(= 2,3); > +extern void inform_n (location_t, int, const char *, const char *, ...) > + =A0 =A0ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5); > =A0extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); > > =A0extern void rest_of_decl_compilation (tree, int, int); > Index: gcc/cp/pt.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/cp/pt.c (revisione 156858) > +++ gcc/cp/pt.c (copia locale) > @@ -4614,10 +4614,14 @@ redeclare_class_template (tree type, tre > > =A0 if (TREE_VEC_LENGTH (parms) !=3D TREE_VEC_LENGTH (tmpl_parms)) > =A0 =A0 { > - =A0 =A0 =A0error ("redeclared with %d template parameter(s)", > - =A0 =A0 =A0 =A0 =A0 =A0 TREE_VEC_LENGTH (parms)); > - =A0 =A0 =A0inform (input_location, "previous declaration %q+D used %d > template parameter(s)", > - =A0 =A0 =A0 =A0 =A0 =A0 tmpl, TREE_VEC_LENGTH (tmpl_parms)); > + =A0 =A0 =A0error_n (input_location, TREE_VEC_LENGTH (parms), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "redeclared with %d template parameter", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "redeclared with %d template parameters", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 TREE_VEC_LENGTH (parms)); > + =A0 =A0 =A0inform_n (input_location, TREE_VEC_LENGTH (tmpl_parms), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"previous declaration %q+D used %d templ= ate parameter", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"previous declaration %q+D used %d templ= ate parameters", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmpl, TREE_VEC_LENGTH (tmpl_parms)); > =A0 =A0 =A0 return false; > =A0 =A0 } > > Index: gcc/po/exgettext > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/po/exgettext =A0 =A0(revisione 156858) > +++ gcc/po/exgettext =A0 =A0(copia locale) > @@ -112,6 +112,8 @@ function keyword_option(line) { > =A0 =A0 else if (args ~ /c$/) > =A0 =A0 =A0 =A0format=3D"c-format" > > + =A0 =A0if (name ~ /_n$/) n =3D n "," (n + 1) > + > =A0 =A0 if (n =3D=3D 1) { keyword =3D "--keyword=3D" name } > =A0 =A0 else { keyword =3D "--keyword=3D" name ":" n } > =A0 =A0 if (format) { > PING! Can someone comment on this or commit it? Marco Poletti