From d9d4d15aef4cd198213c36d364800493d55134ec Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Sep 2024 02:22:23 +0200 Subject: [PATCH] Compiler detection: guard =delete("reason") on Clang Clang advertises support for =delete("reason") even in pre-C++26 language modes, however it also emits a warning if one uses it (because it considers the feature a language extension). I claim it's a Clang bug [1], as SD6 doesn't require language version checks and this specific feature is useful in all language modes, so if an implementation decides to offer it it shouldn't also warn about it being an extension. In any case, this commit works around the issue by disabling the feature on pre-C++26 modes. C++26 doesn't have a __cplusplus macro to use, so I'm just taking > C++23. [1] https://github.com/llvm/llvm-project/issues/109311 Change-Id: If1970acb8f7df23c765ab5da747cb59b7b7a6dc7 Pick-to: 6.8 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 9227daf6365..8e9c64fc5b0 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1024,7 +1024,11 @@ #endif #ifndef Q_DECL_EQ_DELETE_X -# if defined(__cpp_deleted_function) && __cpp_deleted_function >= 202403L +// Clang advertises the feature-testing macro but issues a warning +// if one isn't also using C++26, +// https://github.com/llvm/llvm-project/issues/109311 +# if defined(__cpp_deleted_function) && __cpp_deleted_function >= 202403L \ + && (!defined(Q_CC_CLANG_ONLY) || __cplusplus > 202302L) // C++26 # define Q_DECL_EQ_DELETE_X(reason) = delete(reason) # else # define Q_DECL_EQ_DELETE_X(reason) = delete