summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tools/moc/preprocessor.cpp5
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp23
2 files changed, 25 insertions, 3 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 2c7888b42d..ecf6d7d4de 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -538,12 +538,13 @@ void Preprocessor::substituteUntilNewline(Symbols &substituted, MacroSafeSet saf
continue;
}
} else if (token == PP_DEFINED) {
- test(PP_LPAREN);
+ bool braces = test(PP_LPAREN);
next(PP_IDENTIFIER);
Symbol definedOrNotDefined = symbol();
definedOrNotDefined.token = macros.contains(definedOrNotDefined)? PP_MOC_TRUE : PP_MOC_FALSE;
substituted += definedOrNotDefined;
- test(PP_RPAREN);
+ if (braces)
+ test(PP_RPAREN);
continue;
} else if (token == PP_NEWLINE) {
substituted += symbol();
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index aad095d490..6a84eb244a 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -346,11 +346,28 @@ private slots:
void invalidSlot() {}
#endif
-
friend class Receiver; // task #85783
signals:
friend class Sender; // task #85783
+#define MACRO_DEFINED
+
+#if !(defined MACRO_UNDEF || defined MACRO_DEFINED) || 1
+ void signalInIf1();
+#else
+ void doNotExist();
+#endif
+#if !(!defined MACRO_UNDEF || !defined MACRO_DEFINED) && 1
+ void doNotExist();
+#else
+ void signalInIf2();
+#endif
+#if !(!defined (MACRO_DEFINED) || !defined (MACRO_UNDEF)) && 1
+ void doNotExist();
+#else
+ void signalInIf3();
+#endif
+
public slots:
void const slotWithSillyConst() {}
@@ -756,6 +773,10 @@ void tst_Moc::preprocessorConditionals()
QVERIFY(mobj->indexOfSlot("slotInIf()") != -1);
QVERIFY(mobj->indexOfSlot("slotInLastElse()") != -1);
QVERIFY(mobj->indexOfSlot("slotInElif()") != -1);
+ QVERIFY(mobj->indexOfSignal("signalInIf1()") != -1);
+ QVERIFY(mobj->indexOfSignal("signalInIf2()") != -1);
+ QVERIFY(mobj->indexOfSignal("signalInIf3()") != -1);
+ QVERIFY(mobj->indexOfSignal("doNotExist()") == -1);
}
void tst_Moc::blackslashNewlines()