From de1e15af4460c164913cba00686b1e78bb6c2c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 5 Nov 2018 13:44:30 +0100 Subject: Add support for C++ functions attributes in moc Done-with: Ryan Chu Change-Id: Id7f2ba35ccea79e0a0c316ca2736101b8cd57f97 Fixes: QTBUG-58628 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/tools/moc/tst_moc.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 0acc90fd11..4e5d902aa2 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -71,6 +71,7 @@ #include "grand-parent-gadget-class.h" #include "namespace.h" #include "cxx17-namespaces.h" +#include "cxx-attributes.h" #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header @@ -703,6 +704,7 @@ private slots: void optionsFileError(); void testQNamespace(); void cxx17Namespaces(); + void cxxAttributes(); signals: void sigWithUnsignedArg(unsigned foo); @@ -3908,6 +3910,24 @@ void tst_Moc::cxx17Namespaces() QCOMPARE(QMetaEnum::fromType().value(0), 3); } +void tst_Moc::cxxAttributes() +{ + auto so = CppAttribute::staticMetaObject; + QCOMPARE(so.className(), "CppAttribute"); + QCOMPARE(so.enumeratorCount(), 0); + QVERIFY(so.indexOfSignal("deprecatedSignal") != 1); + for (auto a: {"deprecatedSlot", "deprecatedSlot2", "deprecatedReason", "deprecatedReasonWithLBRACK", + "deprecatedReasonWith2LBRACK", "deprecatedReasonWithRBRACK", "deprecatedReasonWith2RBRACK", + "slotWithArguments" +#if !defined(_MSC_VER) || _MSC_VER >= 1912 + , "noreturnSlot", "noreturnSlot2", "returnInt", "noreturnDeprecatedSlot", + "noreturnSlot3" +#endif + }) { + QVERIFY(so.indexOfSlot(a) != 1); + } +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS -- cgit v1.2.3