From 2b26f801b5b49e2f354da0b67070917d25d5917d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 Mar 2013 16:52:12 +0100 Subject: Make parsing of template arguments more robust. At first, my goal was just to fix Moc::until() to parse properly template arguments containing expressions containing > or >> such as Foo<(8>>2)> But with the test, I realized that normalizeType also requires change not to split the > > too much. And QMetaObjectPrivate::decodeMethodSignature should not interpret the ) within the template parameter as the end of the function. Change-Id: Ia9d3a2a786368aeda1edcf66280d70f64cf05070 Reviewed-by: Lars Knoll --- tests/auto/tools/moc/tst_moc.cpp | 19 +++++++++++++++++++ 1 file changed, 19 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 8ce55cbdf5..e26b02a560 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1538,13 +1538,30 @@ class QTBUG12260_defaultTemplate_Object : public QObject public slots: #if !(defined(Q_CC_GNU) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) || defined(Q_MOC_RUN) void doSomething(QHash values = QHash() ) { Q_UNUSED(values); } + void doSomethingElse(QSharedPointer> 2)> > val + = QSharedPointer> 2)> >() ) + { Q_UNUSED(val); } #else // we want to test the previous function, but gcc < 4.4 seemed to have a bug similar to the one moc has. typedef QHash WorkaroundGCCBug; void doSomething(QHash values = WorkaroundGCCBug() ) { Q_UNUSED(values); } + void doSomethingElse(QSharedPointer> 2)> > val + = (QSharedPointer> 2)> >()) ) + { Q_UNUSED(val); } #endif void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); } + +#if defined(Q_MOC_RUN) || (defined(Q_COMPILER_AUTO_TYPE) && !(defined(Q_CC_CLANG) && (__clang_major__ * 100) + __clang_minor__) < 304) + // There is no Q_COMPILER_>> but if compiler support auto, it should also support >> + void performSomething(QVector> e = QVector>(8 < 1), + QHash> h = QHash>()) + { Q_UNUSED(e); Q_UNUSED(h); } +#else + void performSomething(QVector > e = QVector >(), + QHash > h = (QHash >())) + { Q_UNUSED(e); Q_UNUSED(h); } +#endif }; @@ -1552,6 +1569,8 @@ void tst_Moc::QTBUG12260_defaultTemplate() { QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash)") != -1); QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1); + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomethingElse(QSharedPointer>2)> >)") != -1); + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("performSomething(QVector >,QHash >)") != -1); } void tst_Moc::notifyError() -- cgit v1.2.3 From 2b0f02aa5cc0f7d1b460d2d324d5d08c6f6d61b9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 13 Feb 2014 11:13:30 +0100 Subject: moc: Fix parsing of operator< MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit moc would skip the 'operator' keyword as unknown and try to parse a type again but as it sees the '<' it looks for the corresponding '>' which does not exist types can't start with '<' anyway, so return an invalid type and continue parsing as usual Task-number: QTBUG-36834 Change-Id: If3d27076ef9947abf8c57c594713eece9334d0b0 Reviewed-by: Simon Hausmann Reviewed-by: Jędrzej Nowacki --- tests/auto/tools/moc/tst_moc.cpp | 1 + 1 file changed, 1 insertion(+) (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 e26b02a560..bf2d6afdb4 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -128,6 +128,7 @@ public: emit send(value); } + bool operator< ( const Sender & ) const { /* QTBUG-36834 */ return true;} signals: void send(const String::Type&); void send(const Int::Type&); -- cgit v1.2.3