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 <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Peter Varga 2022-12-16 15:22:17 +01:00
parent 417b61b015
commit 2550568a92
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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