From 09590ee995e551e6e5e38c9a0fb586405d3d4c91 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 15 Jan 2025 12:31:38 +0100 Subject: [PATCH] Fix the unsupported Q_UNREACHABLE_RETURN statement in constexpr functions GCC 8.x does not treat __builtin_unreachable() as constexpr and disallows using the Q_UNREACHABLE_RETURN macro. Guard the statements with the respective checks. Amends b0b34c56a99130bfc9c82cb006653ce6b8f0516e Pick-to: 6.8 Task-number: QTBUG-125285 Fixes: QTBUG-132804 Change-Id: I88cdbe3bae1a336edc255e3e93e8d948bde253da Reviewed-by: Ivan Solovev Reviewed-by: Marc Mutz (cherry picked from commit a57d5b1fd60b6b6848ef8ad9db237941229d7a23) Reviewed-by: Qt Cherry-pick Bot --- src/gui/platform/unix/qgenericunixthemes.cpp | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/platform/unix/qgenericunixthemes.cpp b/src/gui/platform/unix/qgenericunixthemes.cpp index e2037639a4d..1f22800af71 100644 --- a/src/gui/platform/unix/qgenericunixthemes.cpp +++ b/src/gui/platform/unix/qgenericunixthemes.cpp @@ -694,7 +694,12 @@ static constexpr QLatin1StringView settingsPrefix(QKdeThemePrivate::KdeSettingTy case QKdeThemePrivate::KdeSettingType::ToolBarStyle: return QLatin1StringView("Toolbar style/"); } - Q_UNREACHABLE_RETURN(QLatin1StringView()); + // GCC 8.x does not treat __builtin_unreachable() as constexpr +# if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900) + // NOLINTNEXTLINE(qt-use-unreachable-return): Triggers on Clang, breaking GCC 8 + Q_UNREACHABLE(); +# endif + return {}; } static constexpr QKdeThemePrivate::KdeSettingType settingsType(QKdeThemePrivate::KdeSetting setting) @@ -733,7 +738,12 @@ static constexpr QKdeThemePrivate::KdeSettingType settingsType(QKdeThemePrivate: CASE(TooltipBackground, Colors); CASE(TooltipForeground, Colors); }; - Q_UNREACHABLE_RETURN(QKdeThemePrivate::KdeSettingType::Root); + // GCC 8.x does not treat __builtin_unreachable() as constexpr +# if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900) + // NOLINTNEXTLINE(qt-use-unreachable-return): Triggers on Clang, breaking GCC 8 + Q_UNREACHABLE(); +# endif + return QKdeThemePrivate::KdeSettingType::Root; } #undef CASE @@ -799,7 +809,12 @@ static constexpr QLatin1StringView settingsKey(QKdeThemePrivate::KdeSetting sett case QKdeThemePrivate::KdeSetting::TooltipForeground: return QLatin1StringView("Tooltip/ForegroundNormal"); }; - Q_UNREACHABLE_RETURN(QLatin1StringView()); + // GCC 8.x does not treat __builtin_unreachable() as constexpr +# if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900) + // NOLINTNEXTLINE(qt-use-unreachable-return): Triggers on Clang, breaking GCC 8 + Q_UNREACHABLE(); +# endif + return {}; } void QKdeThemePrivate::refresh()