This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
- From: Pedro Alves <palves at redhat dot com>
- To: Michael Eager <eager at eagerm dot com>, Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Mon, 25 Sep 2017 17:06:11 +0100
- Subject: Re: [pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 32AE5C057FA7
- References: <1505995878-10687-1-git-send-email-simon.marchi@ericsson.com> <078ea0b6-71aa-f74d-33fc-859322d4668a@eagerm.com>
On 09/25/2017 03:14 PM, Michael Eager wrote:
> On 09/21/2017 05:11 AM, Simon Marchi wrote:
>> I am getting this warning with clang:
>>
>> /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error:
>> format string is not a string literal [-Werror,-Wformat-nonliteral]
>> vprintf_unfiltered (fmt, args);
>> ^~~
>>
>> Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely,
>> > gcc doesn't warn about non-literal format strings when calling vprintf
>> (or a vprintf-style function, like vprintf_unfiltered). I filed this
>> gcc bug:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206
>
> I'll admit to not being familiar with the nuances of __attribute__
> ((format ...)),
> or why adding this to the function declaration of microblaze_debug()
> would suppress
> a diagnostic on the call to vprintf_unfiltered(),
Because with that the compiler can assume that the 'fmt' argument
as passed down to microblaze_debug is a string literal. I.e.,
the compiler can tell that the argument to vprintf_unfiltered is
itself transitively a string literal.
> but the better fix
> seems to me to
> be to turn off the obviously inappropriate -Wformat-nonliteral option in
> microblaze_debug() using
> #pragma GCC diagnostic ignored "-Wformat-nonliteral"
That doesn't make sense to me.
Thanks,
Pedro Alves