On Thu, Mar 09, 2017 at 12:45:28PM -0500, David Malcolm wrote: > PR target/79926 notes that in: > > sorry ("%s instructions aren't allowed in %s service routine", > isa, (cfun->machine->func_type == TYPE_EXCEPTION > ? "exception" : "interrupt")); > > the text from the second %s won't be translated, but should be. > > This patch reworks the diagnostic by breaking it out into two messages > and marking them with G_() so they're seen by xgettext; a test run of > xgettext confirms that both messages make it into po/gcc.pot (in an > earlier version of the patch I attempted to do it without introducing > a local, but xgettext only picked up on one of the strings). > > gcc/ChangeLog: > PR target/79926 > * config/i386/i386.c (ix86_set_current_function): Make "sorry" > message more amenable to translation. > --- > gcc/config/i386/i386.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index e705a3e..b8688e3 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -7271,9 +7271,15 @@ ix86_set_current_function (tree fndecl) > if (isa != NULL) > { > if (cfun->machine->func_type != TYPE_NORMAL) > - sorry ("%s instructions aren't allowed in %s service routine", > - isa, (cfun->machine->func_type == TYPE_EXCEPTION > - ? "exception" : "interrupt")); > + { > + const char *msgid > + = (cfun->machine->func_type == TYPE_EXCEPTION > + ? G_("%s instructions aren't allowed in" > + " exception service routine") > + : G_("%s instructions aren't allowed in" > + " interrupt service routine")); > + sorry (msgid, isa);
1) aren't should be actually aren%'t (we should probably look through gcc.pot and patch all spots that have n't instead of n%'t in them and are in the gcc-internal-format) 2) I think it should be better to do: sorry (cfun->machine->func_type == TYPE_EXCEPTION ? G_("%s instructions aren%'t allowed in exception " "service routine") : G_("%s instructions aren%'t allowed in interrupt " "service routine")); That way, you don't introduce another -Wformat-security issue Ok for trunk with those changes. Jakub