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 Wed, 29 Apr 2015 17:47:08 +0200, Pedro Alves wrote:
> On 04/11/2015 08:44 PM, Jan Kratochvil wrote:
> 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.

Another problem is that (currently) it would not be possible to turn it off in
the same file.  Therefore the user expression without not get any warnings
which would nullify the goal of this patch.


> 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.

Only some GCC's internal macros are affected and I guess it is better to leave
them alone, therefore #ifndef is better (contrary to forced re-#define).


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

Without that #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
	/tmp/gdbobj-xpU1yB/out4.c:6:0: warning: "__STDC_IEC_559_COMPLEX__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:46:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-xpU1yB/out4.c:7:0: warning: "__STDC_IEC_559__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:38:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-xpU1yB/out4.c:8:0: warning: "__STDC_ISO_10646__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:54:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-xpU1yB/out4.c:9:0: warning: "__STDC_NO_THREADS__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:57:0: note: this is the location of the previous definition^M
	(gdb) FAIL: gdb.compile/compile.exp: Test delimiter with -r

Without that #ifndef/#endif and with -Wno-builtin-macro-redefined one
expectedly gets mostly the same:
	compile -r -- void _gdb_expr(){int i = 5;}^M
	/tmp/gdbobj-sJlZmG/out4.c:5:0: warning: "__LINE__" redefined^M
	/tmp/gdbobj-sJlZmG/out4.c:6:0: warning: "__STDC_IEC_559_COMPLEX__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:46:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-sJlZmG/out4.c:7:0: warning: "__STDC_IEC_559__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:38:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-sJlZmG/out4.c:8:0: warning: "__STDC_ISO_10646__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:54:0: note: this is the location of the previous definition^M
	/tmp/gdbobj-sJlZmG/out4.c:9:0: warning: "__STDC_NO_THREADS__" redefined^M
	In file included from <command-line>:0:0:^M
	/usr/include/stdc-predef.h:57:0: note: this is the location of the previous definition^M
	(gdb) FAIL: gdb.compile/compile.exp: Test delimiter with -r

Using #undef before the #define one gets:
	compile -r -- void _gdb_expr(){int i = 5;}^M
	/tmp/gdbobj-vCA0XG/out4.c:7:0: warning: undefining "__FILE__" [-Wbuiltin-macro-redefined]^M
	/tmp/gdbobj-vCA0XG/out4.c:9:8: warning: undefining "__LINE__"^M
	/tmp/gdbobj-vCA0XG/out4.c:11:8: warning: undefining "__STDC_IEC_559_COMPLEX__"^M
	/tmp/gdbobj-vCA0XG/out4.c:13:8: warning: undefining "__STDC_IEC_559__"^M
	/tmp/gdbobj-vCA0XG/out4.c:15:8: warning: undefining "__STDC_ISO_10646__"^M
	/tmp/gdbobj-vCA0XG/out4.c:17:8: warning: undefining "__STDC_NO_THREADS__"^M
	(gdb) FAIL: gdb.compile/compile.exp: Test delimiter with -r

In the end the #ifndef+#define is not such a problem I think.


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

Yes, almost:
> 
> gdb_test_multiple $test $test {
>     -re "^$test\r\n$gdb_prompt $ $" {
      -re "^$test\r\n$gdb_prompt $" {
> 	pass "$test"
>     }


Thanks,
Jan


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