From: Johannes Schindelin Date: Thu, 27 Mar 2025 11:53:02 +0000 (+0000) Subject: clang: warn when the comma operator is used X-Git-Tag: v2.50.0-rc0~119^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3db4cb987f114186744025432fc201bbea1ccc7b;p=thirdparty%2Fgit.git clang: warn when the comma operator is used 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). Helped-by: Patrick Steinhardt Signed-off-by: Johannes Schindelin Acked-by: Phillip Wood Signed-off-by: Junio C Hamano --- diff --git a/config.mak.dev b/config.mak.dev index 0fd8cc4d35..3142363816 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 diff --git a/meson.build b/meson.build index efe2871c9d..fd8c05dec9 100644 --- a/meson.build +++ b/meson.build @@ -715,6 +715,7 @@ libgit_dependencies = [ ] # Makefile. if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc' foreach cflag : [ + '-Wcomma', '-Wdeclaration-after-statement', '-Wformat-security', '-Wold-style-definition',