Re: [PATCH v2 09/10] clang: warn when the comma operator is used
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 26, 2025, 07:50 UTC
- Message-ID
- <9cd9a690-1258-d96d-33c9-53a3b0f346a1@gmx.de>
- In-Reply-To
- <Z-OWp0NkjrMVQieH@pks.im>
Hi Patrick,
On Wed, 26 Mar 2025, Patrick Steinhardt wrote:
Show 31 quoted lines
> On Tue, Mar 25, 2025 at 11:32:13PM +0000, Johannes Schindelin via GitGitGadget wrote: > > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > > > When compiling Git using `clang`, the `-Wcomma` option can be used to > > warn about code using the comma operator (because it is typically > > unintentional and wants to use the semicolon instead). > > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > config.mak.dev | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/config.mak.dev b/config.mak.dev > > index 0fd8cc4d355..31423638169 100644 > > --- a/config.mak.dev > > +++ b/config.mak.dev > > @@ -40,6 +40,10 @@ DEVELOPER_CFLAGS += -Wvla > > DEVELOPER_CFLAGS += -Wwrite-strings > > DEVELOPER_CFLAGS += -fno-common > > > > +ifneq ($(filter clang9,$(COMPILER_FEATURES)),) > > +DEVELOPER_CFLAGS += -Wcomma > > +endif > > + > > ifneq ($(filter clang4,$(COMPILER_FEATURES)),) > > DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare > > endif > > Let's squash the below diff into this commit. The loop already makes > sure that the compiler supports the flag, so there is no need to special > case Clang.
Okay, will do.
For my curiosity...
Show 7 quoted lines
> diff --git a/meson.build b/meson.build
> index dd231b669b6..a7658d62ea0 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -717,6 +717,7 @@ libgit_dependencies = [ ]
> # Makefile.
> if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc'This `get_argument_syntax() == 'gcc'` condition catches `clang`? What other compilers that aren't GCC does it catch?
Ciao, Johannes
Show 6 quoted lines
> foreach cflag : [ > + '-Wcomma', > '-Wdeclaration-after-statement', > '-Wformat-security', > '-Wold-style-definition', >