This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v5 4/7] compile: Use -Wall, not -w


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]