Fix parsing of #if defined expression
We only need to match the closing parentheses if there was an opening one This has caused mis-parsing of tst_qbytearray.cpp Change-Id: I9d52916e3ed8549c5ddd968092451fef7389a952 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
parent
c888e20f22
commit
96611a677f
@ -538,11 +538,12 @@ void Preprocessor::substituteUntilNewline(Symbols &substituted, MacroSafeSet saf
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (token == PP_DEFINED) {
|
} else if (token == PP_DEFINED) {
|
||||||
test(PP_LPAREN);
|
bool braces = test(PP_LPAREN);
|
||||||
next(PP_IDENTIFIER);
|
next(PP_IDENTIFIER);
|
||||||
Symbol definedOrNotDefined = symbol();
|
Symbol definedOrNotDefined = symbol();
|
||||||
definedOrNotDefined.token = macros.contains(definedOrNotDefined)? PP_MOC_TRUE : PP_MOC_FALSE;
|
definedOrNotDefined.token = macros.contains(definedOrNotDefined)? PP_MOC_TRUE : PP_MOC_FALSE;
|
||||||
substituted += definedOrNotDefined;
|
substituted += definedOrNotDefined;
|
||||||
|
if (braces)
|
||||||
test(PP_RPAREN);
|
test(PP_RPAREN);
|
||||||
continue;
|
continue;
|
||||||
} else if (token == PP_NEWLINE) {
|
} else if (token == PP_NEWLINE) {
|
||||||
|
@ -346,11 +346,28 @@ private slots:
|
|||||||
void invalidSlot() {}
|
void invalidSlot() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
friend class Receiver; // task #85783
|
friend class Receiver; // task #85783
|
||||||
signals:
|
signals:
|
||||||
friend class Sender; // task #85783
|
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:
|
public slots:
|
||||||
void const slotWithSillyConst() {}
|
void const slotWithSillyConst() {}
|
||||||
|
|
||||||
@ -756,6 +773,10 @@ void tst_Moc::preprocessorConditionals()
|
|||||||
QVERIFY(mobj->indexOfSlot("slotInIf()") != -1);
|
QVERIFY(mobj->indexOfSlot("slotInIf()") != -1);
|
||||||
QVERIFY(mobj->indexOfSlot("slotInLastElse()") != -1);
|
QVERIFY(mobj->indexOfSlot("slotInLastElse()") != -1);
|
||||||
QVERIFY(mobj->indexOfSlot("slotInElif()") != -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()
|
void tst_Moc::blackslashNewlines()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user