diff options
author | John Baldwin <jhb@FreeBSD.org> | 2022-02-14 19:48:47 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-03-22 19:22:23 +0000 |
commit | 51666ee9660e12f3e38a43b54fa879c680b0eafa (patch) | |
tree | c5c3a15675bff95993e403caef3a8a110d66d99a | |
parent | 11ab827a1ce4ec10cf16721019d53b94d044afb1 (diff) | |
download | src-51666ee9660e12f3e38a43b54fa879c680b0eafa.tar.gz src-51666ee9660e12f3e38a43b54fa879c680b0eafa.zip |
Disable -Wreturn-type on GCC.
GCC is more pedantic than clang about warning when a function doesn't
handle undefined enum values (see GCC bug 87950). Clang's warning
gives a more pragmatic coverage and should find any real bugs, so
disable the warning for GCC rather than adding __unreachable
annotations to appease GCC.
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D34147
(cherry picked from commit 2f6a842484675bb8fe9fafd40d90c06f13e02403)
-rw-r--r-- | share/mk/bsd.sys.mk | 6 | ||||
-rw-r--r-- | sys/conf/kern.mk | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index f228984719c7..7211b54c1804 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -196,6 +196,12 @@ CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \ -Wno-error=stringop-truncation .endif +.if ${COMPILER_TYPE} == "gcc" +# GCC produces false positives for functions that switch on an +# enum (GCC bug 87950) +CWARNFLAGS+= -Wno-return-type +.endif + # How to handle FreeBSD custom printf format specifiers. .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600 FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 67656914dd1d..0f311fba2b23 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -89,7 +89,11 @@ CWARNEXTRA?= -Wno-uninitialized # the few files that are already known to generate cast-qual warnings. NO_WCAST_QUAL= -Wno-cast-qual .endif -.endif + +# GCC produces false positives for functions that switch on an +# enum (GCC bug 87950) +CWARNFLAGS+= -Wno-return-type +.endif # gcc # This warning is utter nonsense CWARNFLAGS+= -Wno-format-zero-length |