summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-07 13:59:45 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-06-08 15:37:38 +0200
commitc76a2d7c9cfc5e2edd45a30681df51b37125bc01 (patch)
tree67a361050d53518b26206a11465369d970656c84 /tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
parent14b74af0608dc833f836acac4ee93f905b449806 (diff)
normalizeTypeFromSignature: Beware of anonymous struct/union
Do a quick check whether the type name contains an anonymous type. If so, do not try to use optimized version. The simple check should still be faster than calling normalizeType unconditionally. Also only apply the faster version for clang and gcc, instead of all non-MSVC compilers. Applying it to other compilers would require further testing to handle anonymous structs. Moreover, remove space before '(', which is necessary for function pointers. Fixes: QTBUG-94213 Change-Id: I795d1964f7a68daa6f9a5f262816d51ee7728788 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
index 856b56941a..8567288c8b 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
@@ -385,6 +385,11 @@ struct CharTemplate
{
int a;
} x;
+
+ union
+ {
+ int a;
+ } y;
};
void tst_QMetaType::operatorEq_data()
@@ -479,6 +484,16 @@ void tst_QMetaType::typeNameNormalization()
// The string based normalization doesn't handle aliases, QMetaType::fromType() does
// CHECK_TYPE_NORMALIZATION("qulonglong", quint64);
QCOMPARE(QMetaType::fromType<quint64>().name(), "qulonglong");
+
+ // noramlizedType and metatype name agree
+ {
+ auto type = QMetaType::fromType<decltype(CharTemplate<'<'>::x)>();
+ QCOMPARE(type.name(), QMetaObject::normalizedType(type.name()));
+ }
+ {
+ auto type = QMetaType::fromType<decltype(CharTemplate<'<'>::y)>();
+ QCOMPARE(type.name(), QMetaObject::normalizedType(type.name()));
+ }
}
// Compile-time test, it should be possible to register function pointer types