This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 6/7 v2] i386.c: make "sorry" message more amenable to translation (PR target/79926)
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, roland dot illig at gmx dot de, Joseph Myers <joseph at codesourcery dot com>, David Malcolm <dmalcolm at redhat dot com>
- Date: Fri, 10 Mar 2017 21:21:53 -0500
- Subject: [PATCH 6/7 v2] i386.c: make "sorry" message more amenable to translation (PR target/79926)
- Authentication-results: sourceware.org; auth=none
- References: <20170310063314.GS22703@tucnak>
On Fri, 2017-03-10 at 07:33 +0100, Jakub Jelinek wrote:
> 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.
Thanks.
Martin pointed out that the wording of these messages could be improved
by adding an article, and by adding quotes to "no_caller_saved_registers"
Here's a revised version that makes those changes (in addition to
the ones you suggested).
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
OK for trunk?
gcc/ChangeLog:
PR target/79926
* config/i386/i386.c (ix86_set_current_function): Make "sorry"
messages more amenable to translation, and improve wording.
gcc/testsuite/ChangeLog:
PR target/79926
* gcc.target/i386/interrupt-387-err-1.c: Update expected message.
* gcc.target/i386/interrupt-387-err-2.c: Likewise.
* gcc.target/i386/interrupt-bnd-err-1.c: Likewise.
* gcc.target/i386/interrupt-bnd-err-2.c: Likewise.
* gcc.target/i386/interrupt-mmx-err-1.c: Likewise.
* gcc.target/i386/interrupt-mmx-err-2.c: Likewise.
---
gcc/config/i386/i386.c | 13 ++++++++-----
gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c | 4 ++--
gcc/testsuite/gcc.target/i386/interrupt-387-err-2.c | 2 +-
gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c | 4 ++--
gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c | 2 +-
gcc/testsuite/gcc.target/i386/interrupt-mmx-err-1.c | 4 ++--
gcc/testsuite/gcc.target/i386/interrupt-mmx-err-2.c | 2 +-
7 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index e705a3e..9fbf8d0 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7271,12 +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"));
+ sorry (cfun->machine->func_type == TYPE_EXCEPTION
+ ? G_("%s instructions aren%'t allowed in an"
+ " exception service routine")
+ : G_("%s instructions aren%'t allowed in an"
+ " interrupt service routine"),
+ isa);
else
- sorry ("%s instructions aren't allowed in function with "
- "no_caller_saved_registers attribute", isa);
+ sorry ("%s instructions aren%'t allowed in a function with "
+ "the %<no_caller_saved_registers%> attribute", isa);
/* Don't issue the same error twice. */
cfun->machine->func_type = TYPE_NORMAL;
cfun->machine->no_caller_saved_registers = false;
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
index 3fbdc88..8561a3c 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
@@ -6,11 +6,11 @@ typedef unsigned int uword_t __attribute__ ((mode (__word__)));
void
__attribute__((interrupt))
fn1 (void *frame, uword_t error)
-{ /* { dg-message "80387 instructions aren't allowed in exception service routine" } */
+{ /* { dg-message "80387 instructions aren't allowed in an exception service routine" } */
}
void
__attribute__((interrupt))
fn2 (void *frame)
-{ /* { dg-message "80387 instructions aren't allowed in interrupt service routine" } */
+{ /* { dg-message "80387 instructions aren't allowed in an interrupt service routine" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-2.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-2.c
index 3203d64..9810f18 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-2.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-2.c
@@ -4,5 +4,5 @@
void
__attribute__((no_caller_saved_registers))
fn1 (void)
-{ /* { dg-message "80387 instructions aren't allowed in function with no_caller_saved_registers attribute" } */
+{ /* { dg-message "80387 instructions aren't allowed in a function with the 'no_caller_saved_registers' attribute" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c
index e07688e..1126fca 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c
@@ -6,11 +6,11 @@ typedef unsigned int uword_t __attribute__ ((mode (__word__)));
void
__attribute__((interrupt))
fn1 (void *frame)
-{ /* { dg-message "MPX instructions aren't allowed in interrupt service routine" } */
+{ /* { dg-message "MPX instructions aren't allowed in an interrupt service routine" } */
}
void
__attribute__((interrupt))
fn2 (void *frame, uword_t error)
-{ /* { dg-message "MPX instructions aren't allowed in exception service routine" } */
+{ /* { dg-message "MPX instructions aren't allowed in an exception service routine" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c
index 641ca63..5e2d1a6 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c
@@ -4,5 +4,5 @@
void
__attribute__((no_caller_saved_registers))
fn (void *frame)
-{ /* { dg-message "MPX instructions aren't allowed in function with no_caller_saved_registers attribute" } */
+{ /* { dg-message "MPX instructions aren't allowed in a function with the 'no_caller_saved_registers' attribute" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-1.c
index cd1367b..8c14594 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-1.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-1.c
@@ -6,11 +6,11 @@ typedef unsigned int uword_t __attribute__ ((mode (__word__)));
void
__attribute__((interrupt))
fn1 (void *frame)
-{ /* { dg-message "MMX/3Dnow instructions aren't allowed in interrupt service routine" } */
+{ /* { dg-message "MMX/3Dnow instructions aren't allowed in an interrupt service routine" } */
}
void
__attribute__((interrupt))
fn2 (void *frame, uword_t error)
-{ /* { dg-message "MMX/3Dnow instructions aren't allowed in exception service routine" } */
+{ /* { dg-message "MMX/3Dnow instructions aren't allowed in an exception service routine" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-2.c b/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-2.c
index 3e9f70c..073700e 100644
--- a/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-2.c
+++ b/gcc/testsuite/gcc.target/i386/interrupt-mmx-err-2.c
@@ -4,5 +4,5 @@
void
__attribute__((no_caller_saved_registers))
fn1 (void)
-{ /* { dg-message "MMX/3Dnow instructions aren't allowed in function with no_caller_saved_registers attribute" } */
+{ /* { dg-message "MMX/3Dnow instructions aren't allowed in a function with the 'no_caller_saved_registers' attribute" } */
}
--
1.8.5.3