diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-12-05 05:37:37 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-12-08 14:03:55 -0800 |
commit | ead408ca1b0b689bea269543117d89316ab23d0b (patch) | |
tree | 5fc9fe2da719e54445482d053fabb61d3f07fb9f /tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp | |
parent | 0d85d0a72fd0136bd89e201d0cc1bf7fac2c24c8 (diff) |
QMetaType: fix typenameHelper() for types in the QtPrivate namespace
GCC at some point decided that it wouldn't include the full namespace
expansion in __PRETTY_FUNCTION__ for any type that is in the same
namespace as the template function being expanded (that is, the
QtPrivate) namespace. I don't know how long this behavior has been in
place, but it can be seen with GCC 13, where the expansion of that macro
inside QtPrivate::typenameHelper<QtPrivate::ModelIndex>() is:
constexpr auto QtPrivate::typenameHelper() [with T = ModelIndex]
This can be easily worked around by using a different namespace.
Fixes: QTBUG-119650
Pick-to: 6.6 6.5 6.2
Change-Id: Ica7a43f6147b49c187ccfffd179df309e43a70cb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp | 15 |
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 c0650c7b1a..bde4e19907 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp @@ -640,6 +640,21 @@ void tst_QMetaType::typeNameNormalization() } } +QT_BEGIN_NAMESPACE +namespace QtPrivate { struct tst_QMetaType_TestType {}; } +QT_END_NAMESPACE + +void tst_QMetaType::typeNameInQtPrivate() +{ + using T = QT_PREPEND_NAMESPACE(QtPrivate::tst_QMetaType_TestType); + + // some compilers (GCC) are known to suppress the namespace prefix if the + // type and the function where it is expanded on are on the same namespace + static constexpr char expectedName[] = "QtPrivate::tst_QMetaType_TestType"; + QMetaType mt = QMetaType::fromType<T>(); + QCOMPARE(mt.name(), expectedName); +} + #if QT_DEPRECATED_SINCE(6, 0) void tst_QMetaType::testDeprecatedGetters() { |