From db597cc4819f0fae070a8a54f92a415cefbc7a78 Mon Sep 17 00:00:00 2001 From: Debian Qt/KDE Maintainers Date: Sat, 14 May 2022 17:41:01 +0800 Subject: [PATCH] handle even more include in enum cases The solution in d3ed7dac8aa2f4ede0c409254b9dd44842086be0 was needlessly complicated, and broke a valid use case. The issue of no identifier being available to parse after the include has been processed can instead be solved by moving the test for the closing brace after the include processing. Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=87973325f1b99f2b Last-Update: 2022-04-07 Gbp-Pq: Name moc_handle_include.diff --- src/tools/moc/moc.cpp | 3 +-- tests/auto/tools/moc/enum_with_include.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 73899199..28c7a43c 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -305,10 +305,9 @@ bool Moc::parseEnum(EnumDef *def) return IncludeState::NoInclude; }; do { + handleInclude(); if (lookup() == RBRACE) // accept trailing comma break; - if ( handleInclude() == IncludeState::IncludeEnd) - continue; next(IDENTIFIER); def->values += lexem(); handleInclude(); diff --git a/tests/auto/tools/moc/enum_with_include.h b/tests/auto/tools/moc/enum_with_include.h index b8abf77f..cd53ba6a 100644 --- a/tests/auto/tools/moc/enum_with_include.h +++ b/tests/auto/tools/moc/enum_with_include.h @@ -34,6 +34,11 @@ class Foo : public QObject { enum en { #include }; + + enum class en2 { + #include + reference = 42 + }; Q_OBJECT }; #endif