moc: Handle include in enum, take 2
The existing logic broke down when we reentered the enumerator parsing loop, and encountered a INCLUDE_MOC_END token in the first handleInclude call. Fix this by restarting the loop in that case. Amends d8a2456fbf18f60e2d1950585d93aa530df077bf. Fixes: QTBUG-88125 Pick-to: 5.15 Change-Id: I87acaa986a81de53730eddc40bc7d48c15328aba Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
ca85d3370f
commit
d3ed7dac8a
@ -240,6 +240,12 @@ Type Moc::parseType()
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class IncludeState {
|
||||||
|
IncludeBegin,
|
||||||
|
IncludeEnd,
|
||||||
|
NoInclude,
|
||||||
|
};
|
||||||
|
|
||||||
bool Moc::parseEnum(EnumDef *def)
|
bool Moc::parseEnum(EnumDef *def)
|
||||||
{
|
{
|
||||||
bool isTypdefEnum = false; // typedef enum { ... } Foo;
|
bool isTypdefEnum = false; // typedef enum { ... } Foo;
|
||||||
@ -260,18 +266,28 @@ bool Moc::parseEnum(EnumDef *def)
|
|||||||
}
|
}
|
||||||
if (!test(LBRACE))
|
if (!test(LBRACE))
|
||||||
return false;
|
return false;
|
||||||
auto handleInclude = [this]() {
|
auto handleInclude = [this]() -> IncludeState {
|
||||||
if (test(MOC_INCLUDE_BEGIN))
|
bool hadIncludeBegin = false;
|
||||||
|
if (test(MOC_INCLUDE_BEGIN)) {
|
||||||
currentFilenames.push(symbol().unquotedLexem());
|
currentFilenames.push(symbol().unquotedLexem());
|
||||||
|
// we do not return early to handle empty headers in one go
|
||||||
|
hadIncludeBegin = true;
|
||||||
|
}
|
||||||
if (test(NOTOKEN)) {
|
if (test(NOTOKEN)) {
|
||||||
next(MOC_INCLUDE_END);
|
next(MOC_INCLUDE_END);
|
||||||
currentFilenames.pop();
|
currentFilenames.pop();
|
||||||
|
return IncludeState::IncludeEnd;
|
||||||
}
|
}
|
||||||
|
if (hadIncludeBegin)
|
||||||
|
return IncludeState::IncludeBegin;
|
||||||
|
else
|
||||||
|
return IncludeState::NoInclude;
|
||||||
};
|
};
|
||||||
do {
|
do {
|
||||||
if (lookup() == RBRACE) // accept trailing comma
|
if (lookup() == RBRACE) // accept trailing comma
|
||||||
break;
|
break;
|
||||||
handleInclude();
|
if ( handleInclude() == IncludeState::IncludeEnd)
|
||||||
|
continue;
|
||||||
next(IDENTIFIER);
|
next(IDENTIFIER);
|
||||||
def->values += lexem();
|
def->values += lexem();
|
||||||
handleInclude();
|
handleInclude();
|
||||||
|
@ -1 +1,2 @@
|
|||||||
parcel
|
parcel = 42,
|
||||||
|
part = 12,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user