aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2025-03-27 11:53:02 +0000
committerJunio C Hamano <gitster@pobox.com>2025-03-28 17:38:12 -0700
commit3db4cb987f114186744025432fc201bbea1ccc7b (patch)
treee7916262eb667789a9091fa1ce2465116effb592
parent88c91d7d742b802a8774383641f8d997cfd1cd0c (diff)
downloadgit-3db4cb987f114186744025432fc201bbea1ccc7b.tar.xz
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 <ps@pks.im> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--config.mak.dev4
-rw-r--r--meson.build1
2 files changed, 5 insertions, 0 deletions
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',