diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2013-02-19 16:56:30 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-21 16:55:41 +0100 |
commit | b05f19f23217ebf982f021c71a04b1df73827c35 (patch) | |
tree | a4a4bb23e037ef98d5bc0b1bd1b2beec292d618d /tests | |
parent | ec166aaa70d5451d84caf0a1ae984cacecd88d5b (diff) |
moc: Fix infinite recursion in macro substitution
When performing macro argument substitution, one should keep the set of
macro to exclude, else we can enter an infinite recursion.
Testcase:
#define M1(A) A
#define M2 M1(M2)
Task-number: QTBUG-29759
Change-Id: I564bbfed65e1c8599592eaf12c6d67285d2fd9ce
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/moc/parse-defines.h | 5 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 3e5841835d..f12899e368 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -76,6 +76,9 @@ #endif +#define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX) +#define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF) + PD_BEGIN_NAMESPACE class PD_CLASSNAME : public QObject @@ -128,6 +131,8 @@ public slots: void conditionSlot() {} #endif + void PD_DEFINE_ITSELF(int) {} + }; #undef QString diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index f0d1934a93..ee82dc0652 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2772,7 +2772,6 @@ void tst_Moc::parseDefines() } if (!qstrcmp(mci.name(), "TestString2")) { ++count; - qDebug() << mci.value(); QVERIFY(!qstrcmp(mci.value(), "ParseDefine")); } if (!qstrcmp(mci.name(), "TestString3")) { @@ -2781,6 +2780,9 @@ void tst_Moc::parseDefines() } } QVERIFY(count == 3); + + index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)"); + QVERIFY(index != -1); } void tst_Moc::preprocessorOnly() |