https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118991

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fix for avr:
2025-02-25  Jakub Jelinek  <ja...@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.

--- gcc/config/avr/avr.cc.jj    2025-02-24 00:06:25.000000000 +0100
+++ gcc/config/avr/avr.cc       2025-02-25 13:45:58.960806467 +0100
@@ -2750,10 +2750,19 @@ avr_print_operand (FILE *file, rtx x, in
                  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 thre 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

Reply via email to