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>
Johannes Schindelin committed
Mar 27, 2025 at 11:53 UTC
3db4cb987f114186744025432fc201bbea1ccc7b
2 files changed
+5
config.mak.dev
+4
@@ -40,6 +40,10 @@ DEVELOPER_CFLAGS += -Wvla
40
DEVELOPER_CFLAGS += -Wwrite-strings
41
DEVELOPER_CFLAGS += -fno-common
42
43
+ifneq ($(filter clang9,$(COMPILER_FEATURES)),)
44
+DEVELOPER_CFLAGS += -Wcomma
45
+endif
46
+
47
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
48
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
49
endif
meson.build
+1
@@ -715,6 +715,7 @@ libgit_dependencies = [ ]
715
# Makefile.
716
if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc'
717
foreach cflag : [
718
+ '-Wcomma',
719
'-Wdeclaration-after-statement',
720
'-Wformat-security',
721
'-Wold-style-definition',