summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2019-03-01 09:38:45 +0100
committerOliver Wolff <oliver.wolff@qt.io>2019-03-11 14:11:33 +0000
commit2412cfac512cbf54ebd379ee8d7157b251f4932d (patch)
tree486301958ae59515d290ecc3844ce6852c817aff /tests/auto/tools/moc/tst_moc.cpp
parent75c6bd54d7e056e2818f942f9e40b897f575fd34 (diff)
moc: Fix parsing of [[deprecated]] enum values
moc now successfully parses enum values, that have been deprecated with [[deprecated]]. This is valid c++17 and should be handled correctly. By adding that functionality it is possible to parse Windows headers which use this deprecation mechanism. To make sure, that moc works correctly even on compilers that do not support deprecated enum values yet, the auto test explicitly uses [[deprecated]] enum values during moc run. Fixes: QTBUG-74126 Change-Id: I7b9d9a49af6093a97f8fdb800ffbc5af3d54d262 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 4e5d902aa2..f12df578f4 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -3926,6 +3926,23 @@ void tst_Moc::cxxAttributes()
}) {
QVERIFY(so.indexOfSlot(a) != 1);
}
+
+ QCOMPARE(TestQNamespaceDeprecated::staticMetaObject.enumeratorCount(), 2);
+ checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(0), "TestEnum1",
+ {{"Key1", 11}, {"Key2", 12}, {"Key3", 13}, {"Key4", 14}, {"Key5", 15}, {"Key6", 16},
+ {"Key7", 17}});
+ checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(1), "TestFlag1",
+ {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Flag3", 3}, {"Any", 1 | 2 | 3}});
+
+ QCOMPARE(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumeratorCount(), 1);
+ checkEnum(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1",
+ {{"Key1", 13}, {"Key2", 14}, {"Key3", 15}});
+
+ QMetaEnum meta = QMetaEnum::fromType<TestQNamespaceDeprecated::TestEnum1>();
+ QVERIFY(meta.isValid());
+ QCOMPARE(meta.name(), "TestEnum1");
+ QCOMPARE(meta.enclosingMetaObject(), &TestQNamespaceDeprecated::staticMetaObject);
+ QCOMPARE(meta.keyCount(), 7);
}
QTEST_MAIN(tst_Moc)