------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-19 17:28 
-------
Subject: Re:  Re: [Bug c/18059] New: bad diagnostic formatting

On Tue, 19 Oct 2004, nathan at gcc dot gnu dot org wrote:

> c-common.c contains
>   void c_parse_error (const char *msgid, enum cpp_ttype token, tree value)
> 
> which purports to format msgid, however, it contains things like,
>    error ("%s at end of input", string);
> thus any magic %< in MSGID do not get munged.  Resulting in,
>  error: expected %<,%> or %<...%> before '>' token
> 
> There needs to be a nesting mechanism to pass a format string as a % escape.

That the parameter is called msgid simply means it is translated - which 
it is.  There are at least three separate bugs here.

(1) The C++ front end shouldn't, for now, use these escapes in strings 
passed to c_parse_error.

(2) The message parameter to cp_parser_error is called "message" rather 
than "msgid", so the messages don't get in the message catalog.  Much the 
same applies to several other functions in the C++ parser: 
cp_parser_require, cp_parser_name_lookup_error, 
cp_parser_non_integral_constant_expression all take English arguments that 
aren't marked for translation and may not end up getting passed to _() in 
all cases.  cp_parser_require also concatenates the argument with the 
string "expected ".  The type_definition_forbidden_message structure 
member has a similar problem.

(3) c_parse_error combines a string (which may need %< and %>) with 
another part of a sentence with %s.  Combining sentence fragments cannot 
work with i18n, apart from the problems with message formatting.  The 
source code must contain all the full sentences output even though this 
bulks up the source by needing 8 different "expected .. before ..." in the 
error function call for every parser error: only that way can all the 
sentences be translated properly.  Making each call pass eight arguments 
rather than one is fortunately a fairly mechanical change, as the new 
arguments are derived from the existing one in a fixed way.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17852

Reply via email to