]>
Commit | Line | Data |
---|---|---|
27e0c3c6 CMAB |
1 | ifndef COMPILER_FEATURES |
2 | COMPILER_FEATURES := $(shell ./detect-compiler $(CC)) | |
3 | endif | |
4 | ||
99f763ba | 5 | ifeq ($(filter no-error,$(DEVOPTS)),) |
6d5d4b4e | 6 | DEVELOPER_CFLAGS += -Werror |
521dc562 | 7 | SPARSE_FLAGS += -Wsparse-error |
99f763ba | 8 | endif |
ebd2e4a1 | 9 | |
27e0c3c6 | 10 | DEVELOPER_CFLAGS += -Wall |
6a8cbc41 | 11 | ifeq ($(filter no-pedantic,$(DEVOPTS)),) |
6d5d4b4e | 12 | DEVELOPER_CFLAGS += -pedantic |
ebd2e4a1 | 13 | ifneq (($or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),) |
6a8cbc41 | 14 | DEVELOPER_CFLAGS += -Wpedantic |
ebd2e4a1 CMAB |
15 | ifneq ($(filter gcc10,$(COMPILER_FEATURES)),) |
16 | ifeq ($(uname_S),MINGW) | |
6a8cbc41 | 17 | DEVELOPER_CFLAGS += -Wno-pedantic-ms-format |
27e0c3c6 | 18 | endif |
6d5d4b4e | 19 | endif |
ebd2e4a1 CMAB |
20 | endif |
21 | endif | |
5f463853 | 22 | |
2b95d94b | 23 | ifneq ($(uname_S),FreeBSD) |
5f463853 JK |
24 | ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang7,$(COMPILER_FEATURES))),) |
25 | DEVELOPER_CFLAGS += -std=gnu99 | |
26 | endif | |
2b95d94b JH |
27 | else |
28 | # FreeBSD cannot limit to C99 because its system headers unconditionally | |
29 | # rely on C11 features. | |
30 | endif | |
5f463853 | 31 | |
6d5d4b4e ÆAB |
32 | DEVELOPER_CFLAGS += -Wdeclaration-after-statement |
33 | DEVELOPER_CFLAGS += -Wformat-security | |
6d5d4b4e ÆAB |
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 | |
55391836 | 40 | DEVELOPER_CFLAGS += -fno-common |
1da1580e | 41 | |
1da1580e | 42 | ifneq ($(filter clang4,$(COMPILER_FEATURES)),) |
6d5d4b4e | 43 | DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare |
1da1580e NTND |
44 | endif |
45 | ||
46 | ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),) | |
6d5d4b4e | 47 | DEVELOPER_CFLAGS += -Wextra |
1da1580e NTND |
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. | |
6d5d4b4e | 50 | DEVELOPER_CFLAGS += -Wmissing-prototypes |
26d2e4fb | 51 | ifeq ($(filter extra-all,$(DEVOPTS)),) |
1da1580e | 52 | # These are disabled because we have these all over the place. |
6d5d4b4e ÆAB |
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 | |
1da1580e | 57 | endif |
26d2e4fb | 58 | endif |
1da1580e NTND |
59 | |
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 | |
b53a5f24 JK |
62 | # |
63 | # Likewise, gcc older than 4.9 complains about initializing a | |
64 | # struct-within-a-struct using just "{ 0 }" | |
1da1580e NTND |
65 | ifneq ($(filter gcc4,$(COMPILER_FEATURES)),) |
66 | ifeq ($(filter gcc5,$(COMPILER_FEATURES)),) | |
6d5d4b4e | 67 | DEVELOPER_CFLAGS += -Wno-uninitialized |
b53a5f24 | 68 | DEVELOPER_CFLAGS += -Wno-missing-braces |
1da1580e NTND |
69 | endif |
70 | endif | |
5338ed2b | 71 | |
54795d37 JH |
72 | # Old versions of clang complain about initializaing a |
73 | # struct-within-a-struct using just "{0}" rather than "{{0}}". This | |
74 | # error is considered a false-positive and not worth fixing, because | |
75 | # new clang versions do not, so just disable it. | |
76 | # | |
77 | # The "bug" was fixed in upstream clang 9. | |
78 | # | |
79 | # Complicating this is that versions of clang released by Apple have | |
80 | # their own version numbers (associated with the corresponding version | |
81 | # of XCode) unrelated to the official clang version numbers. | |
82 | # | |
83 | # The bug was fixed in Apple clang 12. | |
84 | # | |
85 | ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang | |
86 | ifeq ($(uname_S),Darwin) # if we are on darwin | |
87 | ifeq ($(filter clang12,$(COMPILER_FEATURES)),) # if version < 12 | |
88 | DEVELOPER_CFLAGS += -Wno-missing-braces | |
89 | endif | |
90 | else # not darwin | |
91 | ifeq ($(filter clang9,$(COMPILER_FEATURES)),) # if version < 9 | |
92 | DEVELOPER_CFLAGS += -Wno-missing-braces | |
93 | endif | |
94 | endif | |
95 | endif | |
96 | ||
846a29af CMAB |
97 | # https://bugzilla.redhat.com/show_bug.cgi?id=2075786 |
98 | ifneq ($(filter gcc12,$(COMPILER_FEATURES)),) | |
99 | DEVELOPER_CFLAGS += -Wno-error=stringop-overread | |
100 | endif | |
101 | ||
5338ed2b | 102 | GIT_TEST_PERL_FATAL_WARNINGS = YesPlease |