This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v5 4/7] compile: Use -Wall, not -w
- From: Pedro Alves <palves at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>, gdb-patches at sourceware dot org
- Cc: Phil Muldoon <pmuldoon at redhat dot com>
- Date: Fri, 15 May 2015 17:48:55 +0100
- Subject: Re: [PATCH v5 4/7] compile: Use -Wall, not -w
- Authentication-results: sourceware.org; auth=none
- References: <20150513201615 dot 4051 dot 5261 dot stgit at host1 dot jankratochvil dot net> <20150513201648 dot 4051 dot 13681 dot stgit at host1 dot jankratochvil dot net>
On 05/13/2015 09:16 PM, Jan Kratochvil wrote:
> Hi,
>
> for a reason unknown to me GDB was using -w instead of -Wall for 'compile code'.
> The problem is later patch for 'compile printf' really needs some warnings to
> be able to catch for example missing format string parameters:
> (gdb) compile printf "%d\n"
> GCC does not seem to be able to cancel -w (there is nothing like -no-w).
>
> Besides that I think even 'compile code' can benefit from -Wall.
>
> That #ifndef hack in print_one_macro() is not nice but while GCC does not warn
> for redefinitions like
> #define MACRO val
> #define MACRO val
> together with the GCC build-in macros I haven't found any other way how to
> prevent the macro-redefinition warnings (when -w is no longer in effect).
It'd be good if the commit logs were updated reflecting previous
discussions. For instance, I'd update this like:
~~~
(...)
Besides that I think even 'compile code' can benefit from -Wall.
That #ifndef change in print_one_macro() is needed otherwise we get
macro-redefinition warnings for the GCC built-in macros (as -w is no
longer in effect). For example, without the #ifndef/#endif one gets:
compile -r -- void _gdb_expr(){int i = 5;}^M
/tmp/gdbobj-xpU1yB/out4.c:4:0: warning: "__FILE__" redefined [-Wbuiltin-macro-redefined]^M
/tmp/gdbobj-xpU1yB/out4.c:5:0: warning: "__LINE__" redefined^M
...
It makes more sense to pick the inferior's version of the macros, hence
#ifndef instead of #undef.
(...)
~~~
OK.
Thanks,
Pedro Alves