Silence compiler warning about unreachable code
The warning has been reported by users, but never observed in CI, even though the only path that can lead to the last return statement becoming unreachable is very common in Qt: if a QDebug stream operator exists, then we always return early. Nevertheless, rewrite the code to have a single return statement. Task-number: QTBUG-112371 Fixes: QTBUG-114944 Pick-to: 6.6 6.5 Change-Id: Iaf9ec683ceceedb00771fb0743a09dcc8f50ba3f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
This commit is contained in:
parent
bc64864120
commit
cf5da33367
@ -315,16 +315,17 @@ namespace QTest
|
||||
template <typename T> // Fallback; for built-in types debug streaming must be possible
|
||||
inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value && !std::is_enum_v<T>, char *>::type toString(const T &t)
|
||||
{
|
||||
char *result = nullptr;
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
if constexpr (QTypeTraits::has_ostream_operator_v<QDebug, T>) {
|
||||
return qstrdup(QDebug::toString(t).toUtf8().constData());
|
||||
result = qstrdup(QDebug::toString(t).toUtf8().constData());
|
||||
} else {
|
||||
static_assert(!QMetaTypeId2<T>::IsBuiltIn,
|
||||
"Built-in type must implement debug streaming operator "
|
||||
"or provide QTest::toString specialization");
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename F> // Output QFlags of registered enumerations
|
||||
|
Loading…
x
Reference in New Issue
Block a user