https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109189
Bug ID: 109189
Summary: Format string warnings in gcc/config/h8300/h8300.cc
under MigW-W64/MSYS2
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: internal-improvement
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: jdx at o2 dot pl
Target Milestone: ---
Host: x86_64-w64-mingw32
Target: h8300-elf
Created attachment 54704
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54704&action=edit
Proposed patch
I get the following messages when I build different gcc versions (12.2, master)
for H8/300:
[...]
g++ -fno-PIE -c -g -O2 -DIN_GCC -fPIC -DCROSS_DIRECTORY_STRUCTURE
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing
-Wwrite-strings -Wcast-qual -Wmissing-format-attribute
-Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I.
-I../../../gcc/gcc -I../../../gcc/gcc/. -I../../../gcc/gcc/../include
-I../../../gcc/gcc/../libcpp/include -I../../../gcc/gcc/../libcody
-I../../../gcc/gcc/../libdecnumber -I../../../gcc/gcc/../libdecnumber/dpd
-I../libdecnumber -I../../../gcc/gcc/../libbacktrace -o h8300.o -MT h8300.o
-MMD -MP -MF ./.deps/h8300.TPo ../../../gcc/gcc/config/h8300/h8300.cc
../../../gcc/gcc/config/h8300/h8300.cc: In function 'void
h8300_print_operand(FILE*, rtx, int)':
../../../gcc/gcc/config/h8300/h8300.cc:1447:26: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1447 | fprintf (file, "#%ld", (-INTVAL (x)) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1460:26: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1460 | fprintf (file, "#%ld", ((-INTVAL (x)) & 0xff00) >> 8);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1468:22: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1468 | fprintf (file, "#%ld", 0xff & (-INTVAL (x)));
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1545:26: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1545 | fprintf (file, "#%ld", ((INTVAL (x) >> 16) & 0xffff));
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1570:26: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1570 | fprintf (file, "#%ld", INTVAL (x) & 0xffff);
| ^~~~~~
../../../gcc/gcc/config/h8300/h8300.cc:1624:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1624 | fprintf (file, "#%ld", (INTVAL (x)) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1632:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1632 | fprintf (file, "#%ld", (INTVAL (x) >> 8) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1640:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1640 | fprintf (file, "#%ld", INTVAL (x) & 0xff);
| ^~~~~~
../../../gcc/gcc/config/h8300/h8300.cc:1648:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1648 | fprintf (file, "#%ld", (INTVAL (x) >> 8) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1656:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1656 | fprintf (file, "#%ld", (INTVAL (x) >> 16) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int
../../../gcc/gcc/config/h8300/h8300.cc:1664:24: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'long long int'
[-Wformat=]
1664 | fprintf (file, "#%ld", (INTVAL (x) >> 24) & 0xff);
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long long int