diff options
author | MÃ¥rten Nordheim <marten.nordheim@qt.io> | 2023-11-10 15:08:13 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-11-27 15:57:14 +0000 |
commit | 213ab4256e07d65a61a37c96b0d9d17b56ad8477 (patch) | |
tree | 5c2ba565fe566b448ed78d712541a5970004c022 | |
parent | 526a81b5b69a5e825becfce2c295339235aa84a8 (diff) |
Re-allow names containing ENUM in rep files
Expand the test from just looking for the existence of ENUM
and instead check that a sequence starts with ENUM and is
not followed by a letter.
Pick-to: 6.5
Fixes: QTBUG-117379
Change-Id: Ibf979eff0efee2fd82eac1c5c20a1a8bbc2ef2e6
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 96cfbcc4570fcc4e426fdd6699d3666f49bf5c26)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/repparser/parser.g | 10 | ||||
-rw-r--r-- | tests/auto/repc/enums/enums.rep | 6 | ||||
-rw-r--r-- | tests/auto/repc/enums/tst_enums.cpp | 11 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/repparser/parser.g b/src/repparser/parser.g index 5b05222..a45a14c 100644 --- a/src/repparser/parser.g +++ b/src/repparser/parser.g @@ -890,9 +890,13 @@ Pod: pod; qWarning() << "[repc] - Ignoring POD with no data members. POD name: " << qPrintable(pod.name); return true; } - if (argString.contains(QLatin1String("ENUM"))) { - setErrorString(QLatin1String("ENUMs are only available in PODs using bracket syntax ('{'), not parentheses")); - return false; + for (const QStringView &token : argString.tokenize(u' ')) { + if (token.startsWith(QLatin1String("ENUM"))) { + if (token.size() == 4 || !(token[4].isLetterOrNumber() || token[4] == u'_')) { + setErrorString(QLatin1String("ENUMs are only available in PODs using bracket syntax ('{'), not parentheses")); + return false; + } + } } RepParser::TypeParser parseType; diff --git a/tests/auto/repc/enums/enums.rep b/tests/auto/repc/enums/enums.rep index 190c2fe..3bd26b5 100644 --- a/tests/auto/repc/enums/enums.rep +++ b/tests/auto/repc/enums/enums.rep @@ -4,3 +4,9 @@ USE_ENUM(Qt::DayOfWeek) class TestInterface { }; + +// This needs to generate properly and compile: +ENUM XENUMx {Foo, Bar}; +POD Mode(XENUMxEnum::XENUMx foo); +ENUM ENUM_ {Foo, Bar}; +POD Mode2(ENUM_Enum::ENUM_ foo); diff --git a/tests/auto/repc/enums/tst_enums.cpp b/tests/auto/repc/enums/tst_enums.cpp index 9ba0a41..60ee870 100644 --- a/tests/auto/repc/enums/tst_enums.cpp +++ b/tests/auto/repc/enums/tst_enums.cpp @@ -13,6 +13,7 @@ class tst_Enums : public QObject { private Q_SLOTS: void testMarshalling(); + void testEnumContainingENUM(); }; void tst_Enums::testMarshalling() @@ -50,6 +51,16 @@ void tst_Enums::testMarshalling() } } +void tst_Enums::testEnumContainingENUM() +{ + // We mostly just want to make sure the generation for this doesn't change, + // so test using the type name and the value of the first entry: + XENUMxEnum::XENUMx xenum = XENUMxEnum::Foo; + QCOMPARE(int(xenum), 0); + ENUM_Enum::ENUM_ enum_ = ENUM_Enum::Foo; + QCOMPARE(int(enum_), 0); +} + QTEST_APPLESS_MAIN(tst_Enums) #include "tst_enums.moc" |