git: 63d1c3c43690 - main - bsd.sys.mk: suppress some new clang 21 warnings for C++

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 28 Dec 2025 19:53:22 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=63d1c3c43690ff3c3e76e1fb03c8640fe30a2663

commit 63d1c3c43690ff3c3e76e1fb03c8640fe30a2663
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-12-25 18:44:34 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-28 19:43:12 +0000

    bsd.sys.mk: suppress some new clang 21 warnings for C++
    
    Otherwise, these lead to many -Werror warnings in libc++ headers, due to
    our use of -Wsystem-headers, which is not officially supported upstream:
    
    Suppress -Wc++20-extensions, due to:
    
        /usr/include/c++/v1/__algorithm/simd_utils.h:96:50: error: explicit template parameter list for lambdas is a C++20 extension [-Werror,-Wc++20-extensions]
           96 | inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
              |                                                  ^
    
    Suppress -Wc++23-lambda-attributes, due to:
    
        /usr/include/c++/v1/__format/format_functions.h:462:32: error: an attribute specifier sequence in this position is a C++23 extension [-Werror,-Wc++23-lambda-attributes]
          462 |   if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
              |                                ^
    
    Suppress -Wnullability-completeness, due to:
    
        /usr/include/c++/v1/string:1068:80: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
         1068 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) {
              |                                                                                ^
    
    MFC after:      3 days
---
 share/mk/bsd.sys.mk | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 2134886abcf5..50eb04b9fd15 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -93,6 +93,11 @@ CWARNFLAGS.clang+=	-Wno-error=unused-but-set-parameter
 # Similar to gcc >= 8.1 -Wno-error=cast-function-type below
 CWARNFLAGS.clang+=	-Wno-error=cast-function-type-mismatch
 .endif
+.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 210000
+CXXWARNFLAGS.clang+=	-Wno-c++20-extensions
+CXXWARNFLAGS.clang+=	-Wno-c++23-lambda-attributes
+CXXWARNFLAGS.clang+=	-Wno-nullability-completeness
+.endif
 .endif # WARNS <= 6
 .if ${WARNS} <= 3
 CWARNFLAGS.clang+=	-Wno-tautological-compare -Wno-unused-value\