From 706882073181b5752e94f63fa931f3f10999fb44 Mon Sep 17 00:00:00 2001 From: Debian Qt/KDE Maintainers Date: Fri, 1 Jul 2022 20:49:23 +0100 Subject: [PATCH] handle even more include in enum cases Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=87973325f1b99f2b Last-Update: 2022-04-07 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. 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 738991991..28c7a43cb 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 b8abf77f1..cd53ba6a2 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 -- 2.30.2