From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13794 invoked by alias); 18 Feb 2010 14:33:42 -0000 Received: (qmail 13782 invoked by uid 22791); 18 Feb 2010 14:33:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS 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; Thu, 18 Feb 2010 14:33:37 +0000 Received: by bwz6 with SMTP id 6so184735bwz.16 for ; Thu, 18 Feb 2010 06:33:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.48.202 with SMTP id s10mr5894872bkf.34.1266503614573; Thu, 18 Feb 2010 06:33:34 -0800 (PST) In-Reply-To: References: <206fcf961002170906l1bdca005h3833890d35d7db5c@mail.gmail.com> <4B7C3571.60808@gnu.org> Date: Thu, 18 Feb 2010 14:33:00 -0000 Message-ID: Subject: Re: gcc/cp/pt.c: use ngettext() when needed From: Marco Poletti To: Paolo Bonzini Cc: "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/msg00717.txt.bz2 >> [...] >> So it would be something like >> >> error_n(location_t,int,const char*,const char*, ...) >> >> ? > > Yes, with ... > > Thanks Joseph for pointing out location_t. =A0Also 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 =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 (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 accord= ing 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 =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 (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 =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 if (TREE_VEC_LENGTH (parms) !=3D 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 =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 (revisione 156858) +++ gcc/po/exgettext (copia locale) @@ -112,6 +112,8 @@ function keyword_option(line) { else if (args ~ /c$/) format=3D"c-format" + if (name ~ /_n$/) n =3D n "," (n + 1) + if (n =3D=3D 1) { keyword =3D "--keyword=3D" name } else { keyword =3D "--keyword=3D" name ":" n } if (format) {