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 0/5] Remove a few hurdles of compiling with clang


> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Tue, 13 Jun 2017 12:23:27 +0200
> 
> If somebody is willing to do the work and that it doesn't degrade the code quality,
> we should have no problem accepting it.  So if it's a "side-step" that allows both
> compilers to be happy, that's ok.  As a patch submitter, if you use primarily GCC,
> you are not required to test your patches with Clang, but if you use primarily Clang,
> you must test your patch with GCC (a version that's easily accessible for you).
> 
> Does that sound like a good rule?

Let's not forget that code submitted by someone who is willing to do
the work stays in GDB even when that someone is no longer willing to
support that compiler.  So there are additional factors to consider
when making this decision.

> /home/emaisin/src/binutils-gdb/gdb/nat/x86-dregs.c:209:7: error: variable 'i' is incremented both in the loop header and in the loop body [-Werror,-Wfor-loop-analysis]
>       i++;
>       ^
> /home/emaisin/src/binutils-gdb/gdb/nat/x86-dregs.c:199:32: note: incremented here
>   ALL_DEBUG_ADDRESS_REGISTERS (i)
>                                ^

Why is incrementing a loop variable in the body an error?  It's
perfectly valid code.

> I think
> that eliminating the error like this is better than adding -Wno-for-loop-analysis, because
> if I wrote code like this and it was actually a mistake, I would like the compiler to tell
> me.

Does clang have the equivalent of "#pragma push"?  If it does, we
could disable this warning only for clang and only for that code
snippet.


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