1ifndef COMPILER_FEATURES
2COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
3endif
4
5ifeq ($(filter no-error,$(DEVOPTS)),)
6DEVELOPER_CFLAGS += -Werror
7SPARSE_FLAGS += -Wsparse-error
8endif
9
10DEVELOPER_CFLAGS += -Wall
11ifeq ($(filter no-pedantic,$(DEVOPTS)),)
12DEVELOPER_CFLAGS += -pedantic
13ifneq (($or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
14DEVELOPER_CFLAGS += -Wpedantic
15ifneq ($(filter gcc10,$(COMPILER_FEATURES)),)
16ifeq ($(uname_S),MINGW)
17DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
18endif
19endif
20endif
21endif
22DEVELOPER_CFLAGS += -Wdeclaration-after-statement
23DEVELOPER_CFLAGS += -Wformat-security
24DEVELOPER_CFLAGS += -Wold-style-definition
25DEVELOPER_CFLAGS += -Woverflow
26DEVELOPER_CFLAGS += -Wpointer-arith
27DEVELOPER_CFLAGS += -Wstrict-prototypes
28DEVELOPER_CFLAGS += -Wunused
29DEVELOPER_CFLAGS += -Wvla
30DEVELOPER_CFLAGS += -fno-common
31
32ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
33DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
34endif
35
36ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
37DEVELOPER_CFLAGS += -Wextra
38# if a function is public, there should be a prototype and the right
39# header file should be included. If not, it should be static.
40DEVELOPER_CFLAGS += -Wmissing-prototypes
41ifeq ($(filter extra-all,$(DEVOPTS)),)
42# These are disabled because we have these all over the place.
43DEVELOPER_CFLAGS += -Wno-empty-body
44DEVELOPER_CFLAGS += -Wno-missing-field-initializers
45DEVELOPER_CFLAGS += -Wno-sign-compare
46DEVELOPER_CFLAGS += -Wno-unused-parameter
47endif
48endif
49
50# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
51# not worth fixing since newer compilers correctly stop complaining
52ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
53ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
54DEVELOPER_CFLAGS += -Wno-uninitialized
55endif
56endif
57
58GIT_TEST_PERL_FATAL_WARNINGS = YesPlease
59