From 2550568a92db79b7a313c89a1578e235fc0b27f5 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 16 Dec 2022 15:22:17 +0100 Subject: [PATCH] Enable [[noreturn]] attribute for non-MSVC compilers on Windows Avoids -Wsometimes-uninitialized warnings with clang-cl. Also do not allow to return qt_message_fatal() if built with other compiler than MSVC. Amends 97b32fa0b661c5dd89d525122427496132abb54a Fixes: QTBUG-113351 Change-Id: I9ce87057e764af1e25de93388ae983891df66d2e Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Thiago Macieira --- src/corelib/global/qassert.h | 4 ++-- src/corelib/global/qlogging.cpp | 6 +++--- src/corelib/global/qlogging.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qassert.h b/src/corelib/global/qassert.h index a3cd60b06a2..862a707e75b 100644 --- a/src/corelib/global/qassert.h +++ b/src/corelib/global/qassert.h @@ -18,7 +18,7 @@ QT_BEGIN_NAMESPACE #if defined(__cplusplus) -#ifndef Q_CC_MSVC +#if !defined(Q_CC_MSVC_ONLY) Q_NORETURN #endif Q_DECL_COLD_FUNCTION @@ -32,7 +32,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) # endif #endif -#ifndef Q_CC_MSVC +#if !defined(Q_CC_MSVC_ONLY) Q_NORETURN #endif Q_DECL_COLD_FUNCTION diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index faafc8cff13..a9a3d019c7c 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -163,7 +163,7 @@ Q_TRACE_POINT(qtcore, qt_message_print, int type, const char *category, const ch \snippet code/src_corelib_global_qglobal.cpp 4 */ -#if !defined(Q_CC_MSVC) || defined(Q_CC_CLANG) +#if !defined(Q_CC_MSVC_ONLY) Q_NORETURN #endif static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message); @@ -342,7 +342,7 @@ using namespace QtPrivate; \sa QMessageLogContext, qDebug(), qInfo(), qWarning(), qCritical(), qFatal() */ -#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) +#if defined(Q_CC_MSVC_ONLY) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) noexcept { size_t len = qstrlen(s); @@ -2023,7 +2023,7 @@ static void qt_message_print(const QString &message) static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message) { -#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) +#if defined(Q_CC_MSVC_ONLY) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) wchar_t contextFileL[256]; // we probably should let the compiler do this for us, by declaring QMessageLogContext::file to // be const wchar_t * in the first place, but the #ifdefery above is very complex and we diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index ea1c68b168c..002125f8d9f 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -54,7 +54,7 @@ private: class QLoggingCategory; -#ifdef Q_CC_MSVC +#if defined(Q_CC_MSVC_ONLY) # define QT_MESSAGE_LOGGER_NORETURN #else # define QT_MESSAGE_LOGGER_NORETURN Q_NORETURN