Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Mar 2023 22:28:36 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 51666ee9660e - stable/12 - Disable -Wreturn-type on GCC.
Message-ID:  <202303222228.32MMSa4f001785@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=51666ee9660e12f3e38a43b54fa879c680b0eafa

commit 51666ee9660e12f3e38a43b54fa879c680b0eafa
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-02-14 19:48:47 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-03-22 19:22:23 +0000

    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)
---
 share/mk/bsd.sys.mk | 6 ++++++
 sys/conf/kern.mk    | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303222228.32MMSa4f001785>