AreArgumentsNarrowedBase: Correct logic for narrowing connect() casts
The prior test deemed there to be narrowing if source and destination integral-or-enum types didn't have the same signedness; but all values of an unsigned source type can be represented in a larger signed destination type, so there is no narrowing in this case. Updated QObject test-case to match. Change-Id: I517a5997adcad70e185d7469a8d26788e463cb75 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
be94fc445a
commit
a32424b46c
@ -229,8 +229,14 @@ namespace QtPrivate {
|
||||
(std::is_floating_point<From>::value && std::is_integral<To>::value) ||
|
||||
(std::is_floating_point<From>::value && std::is_floating_point<To>::value && sizeof(From) > sizeof(To)) ||
|
||||
((std::is_integral<From>::value || std::is_enum<From>::value) && std::is_floating_point<To>::value) ||
|
||||
(std::is_integral<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || std::is_signed<From>::value != std::is_signed<To>::value)) ||
|
||||
(std::is_enum<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || IsEnumUnderlyingTypeSigned<From>::value != std::is_signed<To>::value))
|
||||
(std::is_integral<From>::value && std::is_integral<To>::value
|
||||
&& (sizeof(From) > sizeof(To)
|
||||
|| (std::is_signed<From>::value ? !std::is_signed<To>::value
|
||||
: (std::is_signed<To>::value && sizeof(From) == sizeof(To))))) ||
|
||||
(std::is_enum<From>::value && std::is_integral<To>::value
|
||||
&& (sizeof(From) > sizeof(To)
|
||||
|| (IsEnumUnderlyingTypeSigned<From>::value ? !std::is_signed<To>::value
|
||||
: (std::is_signed<To>::value && sizeof(From) == sizeof(To)))))
|
||||
>
|
||||
{
|
||||
};
|
||||
|
@ -6969,10 +6969,10 @@ void tst_QObject::checkArgumentsForNarrowing()
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, short>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, int>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned int>::value));
|
||||
@ -6980,23 +6980,23 @@ void tst_QObject::checkArgumentsForNarrowing()
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, int>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long long>::value));
|
||||
QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long>::value), sizeof(int) >= sizeof(long));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned int, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long long>::value));
|
||||
QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long long>::value), sizeof(long) >= sizeof(long long));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned long long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, long long>::value));
|
||||
@ -7206,28 +7206,28 @@ void tst_QObject::checkArgumentsForNarrowing()
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, short>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, int>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, int>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long>::value));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long long>::value));
|
||||
QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long>::value), sizeof(ScopedEnumBackedByUInt) >= sizeof(long));
|
||||
QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long long>::value));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, short>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, int>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long long>::value));
|
||||
QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long long>::value), sizeof(ScopedEnumBackedByULong) >= sizeof(long long));
|
||||
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, signed char>::value));
|
||||
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, short>::value));
|
||||
|
Loading…
Reference in New Issue
Block a user