1 ifndef COMPILER_FEATURES
2 COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
5 ifeq ($(filter no-error,$(DEVOPTS)),)
6 DEVELOPER_CFLAGS += -Werror
7 SPARSE_FLAGS += -Wsparse-error
10 DEVELOPER_CFLAGS += -Wall
11 ifeq ($(filter no-pedantic,$(DEVOPTS)),)
12 DEVELOPER_CFLAGS += -pedantic
13 ifneq (($or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
14 DEVELOPER_CFLAGS += -Wpedantic
15 ifneq ($(filter gcc10,$(COMPILER_FEATURES)),)
16 ifeq ($(uname_S),MINGW)
17 DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
23 ifneq ($(uname_S),FreeBSD)
24 ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang7,$(COMPILER_FEATURES))),)
25 DEVELOPER_CFLAGS += -std=gnu99
28 # FreeBSD cannot limit to C99 because its system headers unconditionally
29 # rely on C11 features.
32 DEVELOPER_CFLAGS += -Wdeclaration-after-statement
33 DEVELOPER_CFLAGS += -Wformat-security
34 DEVELOPER_CFLAGS += -Wold-style-definition
35 DEVELOPER_CFLAGS += -Woverflow
36 DEVELOPER_CFLAGS += -Wpointer-arith
37 DEVELOPER_CFLAGS += -Wstrict-prototypes
38 DEVELOPER_CFLAGS += -Wunused
39 DEVELOPER_CFLAGS += -Wvla
40 DEVELOPER_CFLAGS += -fno-common
42 ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
43 DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
46 ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
47 DEVELOPER_CFLAGS += -Wextra
48 # if a function is public, there should be a prototype and the right
49 # header file should be included. If not, it should be static.
50 DEVELOPER_CFLAGS += -Wmissing-prototypes
51 ifeq ($(filter extra-all,$(DEVOPTS)),)
52 # These are disabled because we have these all over the place.
53 DEVELOPER_CFLAGS += -Wno-empty-body
54 DEVELOPER_CFLAGS += -Wno-missing-field-initializers
55 DEVELOPER_CFLAGS += -Wno-sign-compare
56 DEVELOPER_CFLAGS += -Wno-unused-parameter
60 # uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
61 # not worth fixing since newer compilers correctly stop complaining
63 # Likewise, gcc older than 4.9 complains about initializing a
64 # struct-within-a-struct using just "{ 0 }"
65 ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
66 ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
67 DEVELOPER_CFLAGS += -Wno-uninitialized
68 DEVELOPER_CFLAGS += -Wno-missing-braces
72 # https://bugzilla.redhat.com/show_bug.cgi?id=2075786
73 ifneq ($(filter gcc12,$(COMPILER_FEATURES)),)
74 DEVELOPER_CFLAGS += -Wno-error=stringop-overread
77 GIT_TEST_PERL_FATAL_WARNINGS = YesPlease