From 212ff817ca63caae4e6814cc50ac3c98eb150497 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 28 Jun 2023 10:39:15 +0200 Subject: [PATCH] Make qt_noop() constexpr and noexcept (for C++) Since qt_noop() is supposed to be a no-op, it should not affect constexpr'ness and noexcept'ness of functions and expressions it's (indirectly) used in. That requires that it be constexpr and noexcept itself. Add the keywords, but guard against use from C. We can't use our Q_ macros (which would enable noexcept for C, too, on some compilers, because qcompilerdetection.h depends on qtnoop.h, and we don't want the circular dependency. Change-Id: Ie5441c423b7942a6c956345126fc7aec99907d25 Reviewed-by: Thiago Macieira (cherry picked from commit 7bad2902f84a44da00a8cbc8e3acbec3b26c6866) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qtnoop.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qtnoop.h b/src/corelib/global/qtnoop.h index ea0cedd9bc9..c84e6c8a99a 100644 --- a/src/corelib/global/qtnoop.h +++ b/src/corelib/global/qtnoop.h @@ -8,6 +8,13 @@ #pragma qt_sync_stop_processing #endif -inline void qt_noop(void) {} +#ifdef __cplusplus +constexpr +#endif +inline void qt_noop(void) +#ifdef __cplusplus + noexcept +#endif +{} #endif // QTNOOP_H