]> git.ipfire.org Git - thirdparty/git.git/commitdiff
clang: warn when the comma operator is used
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 27 Mar 2025 11:53:02 +0000 (11:53 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 29 Mar 2025 00:38:12 +0000 (17:38 -0700)
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>
config.mak.dev
meson.build

index 0fd8cc4d355ebb7428e1d8258154926dedf8827b..31423638169a676fbb8c0c62e345461a4ffdb0e9 100644 (file)
@@ -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
index efe2871c9dba1318297f92ff8b412ce485c84500..fd8c05dec914976c12972ecdce95b5eaafd0e1eb 100644 (file)
@@ -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',