Get rid of Q_COMPILER_CONSTEXPR checks

Is required now.

Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-11-17 13:24:46 +01:00
parent 1e9dc3ec2f
commit 34304e3100
15 changed files with 4 additions and 71 deletions

View File

@ -1601,16 +1601,10 @@ namespace Qt {
TitleBarArea // For move TitleBarArea // For move
}; };
#if defined(Q_COMPILER_CONSTEXPR)
enum class Initialization { enum class Initialization {
Uninitialized Uninitialized
}; };
[[maybe_unused]] static constexpr Initialization Uninitialized = Initialization::Uninitialized; [[maybe_unused]] static inline constexpr Initialization Uninitialized = Initialization::Uninitialized;
#else
enum Initialization {
Uninitialized
};
#endif
enum CoordinateSystem { enum CoordinateSystem {
DeviceCoordinates, DeviceCoordinates,

View File

@ -361,15 +361,13 @@ struct QRandomGenerator::SystemAndGlobalGenerators
SystemGenerator sys; SystemGenerator sys;
alignas(64) std::aligned_storage<sizeof(QRandomGenerator64), 64>::type global_; alignas(64) std::aligned_storage<sizeof(QRandomGenerator64), 64>::type global_;
#ifdef Q_COMPILER_CONSTEXPR
constexpr SystemAndGlobalGenerators() constexpr SystemAndGlobalGenerators()
: globalPRNGMutex{}, system_{0}, sys{}, global_{} : globalPRNGMutex{}, system_{0}, sys{}, global_{}
{} {}
#endif
void confirmLiteral() void confirmLiteral()
{ {
#if defined(Q_COMPILER_CONSTEXPR) && !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY) #if !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY)
// Currently fails to compile with MSVC 2017, saying QBasicMutex is not // Currently fails to compile with MSVC 2017, saying QBasicMutex is not
// a literal type. Disassembly with MSVC 2013 and 2015 shows it is // a literal type. Disassembly with MSVC 2013 and 2015 shows it is
// actually a literal; MSVC 2017 has a bug relating to this, so we're // actually a literal; MSVC 2017 has a bug relating to this, so we're

View File

@ -504,7 +504,6 @@ constexpr inline bool ascii_isspace(uchar c)
return c >= 1u && c <= 32u && (AsciiSpaceMask >> uint(c - 1)) & 1u; return c >= 1u && c <= 32u && (AsciiSpaceMask >> uint(c - 1)) & 1u;
} }
#if defined(Q_COMPILER_CONSTEXPR)
static_assert(ascii_isspace(' ')); static_assert(ascii_isspace(' '));
static_assert(ascii_isspace('\t')); static_assert(ascii_isspace('\t'));
static_assert(ascii_isspace('\n')); static_assert(ascii_isspace('\n'));
@ -518,7 +517,6 @@ static_assert(!ascii_isspace('\177'));
static_assert(!ascii_isspace(uchar('\200'))); static_assert(!ascii_isspace(uchar('\200')));
static_assert(!ascii_isspace(uchar('\xA0'))); static_assert(!ascii_isspace(uchar('\xA0')));
static_assert(!ascii_isspace(uchar('\377'))); static_assert(!ascii_isspace(uchar('\377')));
#endif
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -478,11 +478,7 @@ template <typename X> struct QAtomicOps
} }
}; };
#if defined(Q_COMPILER_CONSTEXPR)
# define Q_BASIC_ATOMIC_INITIALIZER(a) { a } # define Q_BASIC_ATOMIC_INITIALIZER(a) { a }
#else
# define Q_BASIC_ATOMIC_INITIALIZER(a) { ATOMIC_VAR_INIT(a) }
#endif
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -49,7 +49,7 @@
// If C++11 atomics are supported, use them! // If C++11 atomics are supported, use them!
// Note that constexpr support is sometimes disabled in QNX or INTEGRITY builds, // Note that constexpr support is sometimes disabled in QNX or INTEGRITY builds,
// but their libraries have <atomic>. // but their libraries have <atomic>.
#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX) || defined(Q_OS_INTEGRITY)) #elif defined(Q_COMPILER_ATOMICS)
# include <QtCore/qatomic_cxx11.h> # include <QtCore/qatomic_cxx11.h>
// We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support // We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support
@ -75,16 +75,7 @@ QT_END_NAMESPACE
// New atomics // New atomics
#if defined(Q_COMPILER_CONSTEXPR)
# if defined(Q_CC_CLANG) && Q_CC_CLANG < 303
/*
Do not define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS for Clang before version 3.3.
For details about the bug: see http://llvm.org/bugs/show_bug.cgi?id=12670
*/
# else
#define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS #define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
# endif
#endif
template <typename T> template <typename T>
class QBasicAtomicInteger class QBasicAtomicInteger

View File

@ -207,9 +207,7 @@ public:
template <typename T, typename ConstantsType> template <typename T, typename ConstantsType>
constexpr inline QFreeList<T, ConstantsType>::QFreeList() constexpr inline QFreeList<T, ConstantsType>::QFreeList()
: :
#if defined(Q_COMPILER_CONSTEXPR)
_v{}, // uniform initialization required _v{}, // uniform initialization required
#endif
_next(ConstantsType::InitialNextValue) _next(ConstantsType::InitialNextValue)
{ } { }

View File

@ -511,9 +511,7 @@ static void QT_FASTCALL rbSwap(uchar *dst, const uchar *src, int count)
constexpr uchar gShift = greenShift<Format>(); constexpr uchar gShift = greenShift<Format>();
constexpr uchar bWidth = blueWidth<Format>(); constexpr uchar bWidth = blueWidth<Format>();
constexpr uchar bShift = blueShift<Format>(); constexpr uchar bShift = blueShift<Format>();
#ifdef Q_COMPILER_CONSTEXPR
static_assert(rWidth == bWidth); static_assert(rWidth == bWidth);
#endif
constexpr uint redBlueMask = (1 << rWidth) - 1; constexpr uint redBlueMask = (1 << rWidth) - 1;
constexpr uint alphaGreenMask = (((1 << aWidth) - 1) << aShift) constexpr uint alphaGreenMask = (((1 << aWidth) - 1) << aShift)
| (((1 << gWidth) - 1) << gShift); | (((1 << gWidth) - 1) << gShift);

View File

@ -829,11 +829,7 @@ class StaticDayOfWeekAssociativeArray {
static constexpr int day2idx(Qt::DayOfWeek day) noexcept { return int(day) - 1; } // alt: day % 7 static constexpr int day2idx(Qt::DayOfWeek day) noexcept { return int(day) - 1; } // alt: day % 7
public: public:
constexpr StaticDayOfWeekAssociativeArray() noexcept(noexcept(T())) constexpr StaticDayOfWeekAssociativeArray() noexcept(noexcept(T()))
#ifdef Q_COMPILER_CONSTEXPR
: contained{}, data{} // arrays require uniform initialization : contained{}, data{} // arrays require uniform initialization
#else
: contained(), data()
#endif
{} {}
constexpr bool contains(Qt::DayOfWeek day) const noexcept { return contained[day2idx(day)]; } constexpr bool contains(Qt::DayOfWeek day) const noexcept { return contained[day2idx(day)]; }

View File

@ -105,7 +105,6 @@ constexpr Qt::MouseButtons testRelaxedConstExpr()
void tst_QFlags::constExpr() void tst_QFlags::constExpr()
{ {
#ifdef Q_COMPILER_CONSTEXPR
Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton;
switch (btn) { switch (btn) {
case Qt::LeftButton: QVERIFY(false); break; case Qt::LeftButton: QVERIFY(false); break;
@ -125,10 +124,7 @@ void tst_QFlags::constExpr()
QVERIFY(!verifyConstExpr<Qt::RightButton>(~Qt::MouseButtons(Qt::LeftButton))); QVERIFY(!verifyConstExpr<Qt::RightButton>(~Qt::MouseButtons(Qt::LeftButton)));
#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
QVERIFY(verifyConstExpr<uint(testRelaxedConstExpr())>(Qt::MiddleButton)); QVERIFY(verifyConstExpr<uint(testRelaxedConstExpr())>(Qt::MiddleButton));
#endif
#endif
} }
void tst_QFlags::signedness() void tst_QFlags::signedness()

View File

@ -2182,7 +2182,6 @@ struct RegisterMetaTypeStruct<qRegisterMetaType< Name >()> \
enum { Value = qRegisterMetaType< Name >() }; \ enum { Value = qRegisterMetaType< Name >() }; \
}; };
#if defined(Q_COMPILER_CONSTEXPR)
QT_FOR_EACH_STATIC_TYPE(METATYPE_ID_STRUCT) QT_FOR_EACH_STATIC_TYPE(METATYPE_ID_STRUCT)
QT_FOR_EACH_STATIC_TYPE(REGISTER_METATYPE_STRUCT) QT_FOR_EACH_STATIC_TYPE(REGISTER_METATYPE_STRUCT)
@ -2197,11 +2196,9 @@ struct RegisterMetaTypeStructDefaultTemplateValue
{ {
enum { Value }; enum { Value };
}; };
#endif
void tst_QMetaType::constexprMetaTypeIds() void tst_QMetaType::constexprMetaTypeIds()
{ {
#if defined(Q_COMPILER_CONSTEXPR)
int id = 0; int id = 0;
int metaType; int metaType;
@ -2217,9 +2214,6 @@ void tst_QMetaType::constexprMetaTypeIds()
default:; default:;
} }
Q_UNUSED(metaType); Q_UNUSED(metaType);
#else
QSKIP("The test needs a compiler supporting constexpr");
#endif
} }
void tst_QMetaType::constRefs() void tst_QMetaType::constRefs()
@ -2228,9 +2222,7 @@ void tst_QMetaType::constRefs()
QCOMPARE(::qMetaTypeId<const QString &>(), ::qMetaTypeId<QString>()); QCOMPARE(::qMetaTypeId<const QString &>(), ::qMetaTypeId<QString>());
QCOMPARE(::qMetaTypeId<const CustomMovable &>(), ::qMetaTypeId<CustomMovable>()); QCOMPARE(::qMetaTypeId<const CustomMovable &>(), ::qMetaTypeId<CustomMovable>());
QCOMPARE(::qMetaTypeId<const QList<CustomMovable> &>(), ::qMetaTypeId<QList<CustomMovable> >()); QCOMPARE(::qMetaTypeId<const QList<CustomMovable> &>(), ::qMetaTypeId<QList<CustomMovable> >());
#if defined(Q_COMPILER_CONSTEXPR)
static_assert(::qMetaTypeId<const int &>() == ::qMetaTypeId<int>()); static_assert(::qMetaTypeId<const int &>() == ::qMetaTypeId<int>());
#endif
} }
struct CustomConvertibleType struct CustomConvertibleType

View File

@ -281,7 +281,6 @@ private:
void tst_QStringView::constExpr() const void tst_QStringView::constExpr() const
{ {
// compile-time checks // compile-time checks
#ifdef Q_COMPILER_CONSTEXPR
{ {
constexpr QStringView sv; constexpr QStringView sv;
static_assert(sv.size() == 0); static_assert(sv.size() == 0);
@ -363,7 +362,6 @@ void tst_QStringView::constExpr() const
static_assert(sv3.isEmpty()); static_assert(sv3.isEmpty());
static_assert(sv3.size() == 0); static_assert(sv3.size() == 0);
} }
#endif
} }
void tst_QStringView::basics() const void tst_QStringView::basics() const

View File

@ -154,18 +154,11 @@ template <bool> inline void booleanHelper()
template <typename Atomic> template <typename Atomic>
static void constexprFunctionsHelperTemplate() static void constexprFunctionsHelperTemplate()
{ {
#ifdef Q_COMPILER_CONSTEXPR
// this is a compile-time test only // this is a compile-time test only
booleanHelper<Atomic::isReferenceCountingWaitFree()>(); booleanHelper<Atomic::isReferenceCountingWaitFree()>();
booleanHelper<Atomic::isTestAndSetWaitFree()>(); booleanHelper<Atomic::isTestAndSetWaitFree()>();
booleanHelper<Atomic::isFetchAndStoreWaitFree()>(); booleanHelper<Atomic::isFetchAndStoreWaitFree()>();
booleanHelper<Atomic::isFetchAndAddWaitFree()>(); booleanHelper<Atomic::isFetchAndAddWaitFree()>();
#elif 0 // No longer constexpr
booleanHelper<Atomic::isReferenceCountingNative()>();
booleanHelper<Atomic::isTestAndSetNative()>();
booleanHelper<Atomic::isFetchAndStoreNative()>();
booleanHelper<Atomic::isFetchAndAddNative()>();
#endif
} }
void tst_QAtomicInt::warningFreeHelper() void tst_QAtomicInt::warningFreeHelper()

View File

@ -196,18 +196,11 @@ void tst_QAtomicIntegerXX::static_checks()
(void) QAtomicInteger<T>::isFetchAndAddNative(); (void) QAtomicInteger<T>::isFetchAndAddNative();
(void) QAtomicInteger<T>::isFetchAndAddWaitFree(); (void) QAtomicInteger<T>::isFetchAndAddWaitFree();
#ifdef Q_COMPILER_CONSTEXPR
// this is a compile-time test only // this is a compile-time test only
booleanHelper<QAtomicInteger<T>::isReferenceCountingWaitFree()>(); booleanHelper<QAtomicInteger<T>::isReferenceCountingWaitFree()>();
booleanHelper<QAtomicInteger<T>::isTestAndSetWaitFree()>(); booleanHelper<QAtomicInteger<T>::isTestAndSetWaitFree()>();
booleanHelper<QAtomicInteger<T>::isFetchAndStoreWaitFree()>(); booleanHelper<QAtomicInteger<T>::isFetchAndStoreWaitFree()>();
booleanHelper<QAtomicInteger<T>::isFetchAndAddWaitFree()>(); booleanHelper<QAtomicInteger<T>::isFetchAndAddWaitFree()>();
#elif 0 // no longer constexpr
booleanHelper<QAtomicInteger<T>::isReferenceCountingNative()>();
booleanHelper<QAtomicInteger<T>::isTestAndSetNative()>();
booleanHelper<QAtomicInteger<T>::isFetchAndStoreNative()>();
booleanHelper<QAtomicInteger<T>::isFetchAndAddNative()>();
#endif
} }
void tst_QAtomicIntegerXX::addData() void tst_QAtomicIntegerXX::addData()

View File

@ -64,10 +64,8 @@ private slots:
void globalColors_data(); void globalColors_data();
void globalColors(); void globalColors();
#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT)
void colorConstants_data(); void colorConstants_data();
void colorConstants(); void colorConstants();
#endif
void setRed(); void setRed();
void setGreen(); void setGreen();
@ -373,7 +371,6 @@ void tst_QColor::globalColors()
QCOMPARE(color.rgba(), argb); QCOMPARE(color.rgba(), argb);
} }
#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT)
void tst_QColor::colorConstants_data() void tst_QColor::colorConstants_data()
{ {
QTest::addColumn<QColor>("color"); QTest::addColumn<QColor>("color");
@ -556,7 +553,6 @@ void tst_QColor::colorConstants()
QFETCH(QRgb, argb); QFETCH(QRgb, argb);
QCOMPARE(color.rgba(), argb); QCOMPARE(color.rgba(), argb);
} }
#endif // defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT)
/* /*
CSS color names = SVG 1.0 color names + transparent (rgba(0,0,0,0)) CSS color names = SVG 1.0 color names + transparent (rgba(0,0,0,0))

View File

@ -50,15 +50,11 @@ private Q_SLOTS:
void tst_QSslEllipticCurve::constExpr() void tst_QSslEllipticCurve::constExpr()
{ {
#ifdef Q_COMPILER_CONSTEXPR
// check that default ctor and op ==/!= are constexpr: // check that default ctor and op ==/!= are constexpr:
char array1[QSslEllipticCurve() == QSslEllipticCurve() ? 1 : -1]; char array1[QSslEllipticCurve() == QSslEllipticCurve() ? 1 : -1];
char array2[QSslEllipticCurve() != QSslEllipticCurve() ? -1 : 1]; char array2[QSslEllipticCurve() != QSslEllipticCurve() ? -1 : 1];
Q_UNUSED(array1); Q_UNUSED(array1);
Q_UNUSED(array2); Q_UNUSED(array2);
#else
QSKIP("This test requires C++11 generalized constant expression support enabled in the compiler.");
#endif
} }
void tst_QSslEllipticCurve::construction() void tst_QSslEllipticCurve::construction()