Skip to content

Commit 6b6cd55

Browse files
committed
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>
1 parent b8405f3 commit 6b6cd55

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

config.mak.dev

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ DEVELOPER_CFLAGS += -Wvla
4040
DEVELOPER_CFLAGS += -Wwrite-strings
4141
DEVELOPER_CFLAGS += -fno-common
4242

43+
ifneq ($(filter clang9,$(COMPILER_FEATURES)),)
44+
DEVELOPER_CFLAGS += -Wcomma
45+
endif
46+
4347
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
4448
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
4549
endif

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ libgit_dependencies = [ ]
715715
# Makefile.
716716
if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc'
717717
foreach cflag : [
718+
'-Wcomma',
718719
'-Wdeclaration-after-statement',
719720
'-Wformat-security',
720721
'-Wold-style-definition',

0 commit comments

Comments
 (0)