Re: [PATCH v2 6/7] sim/ppc: Add ATTRIBUTE_PRINTF

Jan-Benedict Glaw
2022-10-12T08:29:56Z

[-- Attachment #1: Type: text/plain, Size: 3265 bytes --]

On Tue, 2022-10-11 15:27:30 +0100, Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> wrote:
> Tsukasa OI <research_trasio@irq.a4lg.com> writes:
>
> > Clang generates a warning if the format string of a printf-like function is
> > not a literal ("-Wformat-nonliteral"). On the default configuration, it
> > causes a build failure (unless "--disable-werror" is specified).
> >
> > To avoid warnings on the printf-like wrapper, it requires proper
> > __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.
> >
> > This commit adds ATTRIBUTE_PRINTF to the printf-like functions.
>
> I've pushed this patch, but I moved all the ATTRIBUTE_PRINTF attributes
> to the function declarations.
>
> Also, one of the definitions already had an ATTRIBUTE_NORETURN, I moved
> this to the declaration too.

Building with a recent GCC, I get this:

$ .../configure --prefix=/tmp/gdb-ppc-elf --target=ppc-elf
$ make V=1 all-gdb
[...]
/usr/lib/gcc-snapshot/bin/gcc -c -g -O2 -Werror -DDEFAULT_INLINE=0 -DWITH_SMP=5 -DHAVE_TERMIOS_STRUCTURE -DHAVE_TERMIOS_CLINE -DHAVE_DEVZERO -Wall -Wdeclaration-after-statement -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wno-error=maybe-uninitialized -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wpointer-sign -Wold-style-declaration -I. -I. -I./../../include -I../../bfd -I./../../bfd -I../../gdb -I./../../gdb -I./../../gdb/config -I../.. -I./../../gnulib/import -I../../gnulib/import -DHAVE_COMMON_FPU -I../common -I./../common emul_generic.c
/usr/lib/gcc-snapshot/bin/gcc -c -g -O2 -Werror -DDEFAULT_INLINE=0 -DWITH_SMP=5 -DHAVE_TERMIOS_STRUCTURE -DHAVE_TERMIOS_CLINE -DHAVE_DEVZERO -Wall -Wdeclaration-after-statement -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wno-error=maybe-uninitialized -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wpointer-sign -Wold-style-declaration -I. -I. -I./../../include -I../../bfd -I./../../bfd -I../../gdb -I./../../gdb -I./../../gdb/config -I../.. -I./../../gnulib/import -I../../gnulib/import -DHAVE_COMMON_FPU -I../common -I./../common emul_bugapi.c
emul_bugapi.c: In function 'emul_bugapi_instruction_call':
emul_bugapi.c:495:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'spreg' {aka 'unsigned int'} [-Werror=format=]
495 | error("emul-bugapi: unimplemented bugapi %s from address 0x%lx\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:144: emul_bugapi.o] Error 1
make[3]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim/ppc'
make[2]: *** [Makefile:1933: all-recursive] Error 1
make[2]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim'
make[1]: *** [Makefile:1185: all] Error 2
make[1]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim'
make: *** [Makefile:11309: all-sim] Error 2

MfG, JBG

--

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]