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 v3 5/9] compile: Use -Wall, not -w


On 04/11/2015 08:44 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).

I think GCC also knows how to suppress such warnings if the redefinitions
are in system includes.  So I guess GCC already has the smarts
to suppress those. '#pragma GCC system_header' might be close, though it may
be ignored if not done on a header.

Note we have #pragma GCC user_expression, which is a pragma handled by
the GCC plugin:

 static void
 plugin_init_extra_pragmas (void *, void *)
 {
   c_register_pragma ("GCC", "user_expression", plugin_pragma_user_expression);
 }

So if we need to, we can easily add another gdb-specific pragma that
enables whatever mode in gcc we need, and wrap the macros with that.

OTOH, if it's the inferior's version of the macro that is always wanted,
then #ifndef should be fine.  If it's gdb's version that is wanted though,
then that could be handled by an #undef before the #define.

But then again, I'm not exactly sure on what you mean by build-in
macros here.  Can you give an example?

>  
> -gdb_test_no_output "compile code struct_object.selffield = &struct_object"
> +set test "compile code struct_object.selffield = &struct_object"
> +gdb_test_multiple $test $test {
> +    -re "gdb command line:1:25: warning: assignment discards 'volatile' qualifier from pointer target type \\\[-Wdiscarded-qualifiers\\\]\r\n$gdb_prompt $" {
> +	xfail "$test (PR compile/18202)"
> +    }
> +}

Please leave a PASS path in place.  I think this would work:

gdb_test_multiple $test $test {
    -re "^$test\r\n$gdb_prompt $ $" {
	pass "$test"
    }
    -re "gdb command line:1:25: warning: assignment discards 'volatile' qualifier from pointer target type \\\[-Wdiscarded-qualifiers\\\]\r\n$gdb_prompt $" {
	xfail "$test (PR compile/18202)"
    }
}

Other than resolving/clarifying the #ifdef issue, this looks
good to me.

Thanks,
Pedro Alves


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