[gcc r15-7780] avr: Fix up avr_print_operand diagnostics [PR118991]
Jakub Jelinek
jakub@gcc.gnu.org
Sun Mar 2 10:31:23 GMT 2025
https://gcc.gnu.org/g:047b7f9a5665a5cb1267861deece3e5d6ce5c5fb
commit r15-7780-g047b7f9a5665a5cb1267861deece3e5d6ce5c5fb
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sun Mar 2 11:30:35 2025 +0100
avr: Fix up avr_print_operand diagnostics [PR118991]
As can be seen in gcc/po/gcc.pot:
#: config/avr/avr.cc:2754
#, c-format
msgid "bad I/O address 0x"
msgstr ""
exgettext couldn't retrieve the whole format string in this case,
because it uses a macro in the middle. output_operand_lossage
is c-format function though, so we can't use %wx to print HOST_WIDE_INT,
and HOST_WIDE_INT_PRINT_HEX_PURE is on some hosts %lx, on others %llx
and on others %I64x so isn't really translatable that way.
As Joseph mentioned in the PR, there is no easy way around this
but go through a temporary buffer, which the following patch does.
2025-03-02 Jakub Jelinek <jakub@redhat.com>
PR translation/118991
* config/avr/avr.cc (avr_print_operand): Print ival into
a temporary buffer and use %s in output_operand_lossage to make
the diagnostics translatable.
Diff:
---
gcc/config/avr/avr.cc | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index d53453e25fdf..71c03b421489 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -2750,10 +2750,19 @@ avr_print_operand (FILE *file, rtx x, int code)
fprintf (file, HOST_WIDE_INT_PRINT_HEX, ival - sfr0);
}
else
- output_operand_lossage
- ("bad I/O address 0x" HOST_WIDE_INT_PRINT_HEX_PURE
- " outside of valid range [0x%x, 0x%x] for %%i operand",
- ival, sfr0, sfr0 + 0x3f);
+ {
+ char buf[17];
+ /* Printed indirectly through buffer, as
+ output_operand_lossage is translatable but uses printf
+ format strings, so HOST_WIDE_INT_PRINT_HEX_PURE macro can't
+ be used there to make translation possible and how exactly
+ can be HOST_WIDE_INT printed is host dependent. */
+ snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_HEX_PURE,
+ ival);
+ output_operand_lossage ("bad I/O address 0x%s outside of "
+ "valid range [0x%x, 0x%x] for %%i "
+ "operand", buf, sfr0, sfr0 + 0x3f);
+ }
}
break; // CONST_INT
More information about the Gcc-cvs
mailing list