From 420ca3463ee8adf2d986af5802d8da4bb24ce14d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 31 Jul 2024 08:25:55 +0200 Subject: [PATCH] tst_QUuid: fix -Wreturn-type in make_minimal(QUuid::Version) The code relies on -Wswitch, but lacked the Q_UNREACHABLE_RETURN() at the end that compiler and code readers need to understand that we don't accept values other than those enumerated, even though an enum variable could hold other values, too. Since the function is constexpr, can't use that macro directly, but need to copy the usual GCC 8 magic incantation. Amends 171ff57be1b8fd1c1b33cffbffa389790f239b5c. Pick-to: 6.9 6.8 Change-Id: I6c9dd0e4178211f57da61aa6df70f8036370f158 Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 531200ed041..332a5be041a 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -462,6 +462,12 @@ constexpr QUuid make_minimal(QUuid::Variant variant) case V::Reserved: return {0, 0, 0, uchar(variant << 5), 0, 0, 0, 0, 0, 0, 0}; } + // 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 tst_QUuid::ordering_data()