diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2023-11-10 15:08:13 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2023-11-27 13:19:48 +0100 |
commit | 96cfbcc4570fcc4e426fdd6699d3666f49bf5c26 (patch) | |
tree | 02c0d45a6c246f7a3e298d979e54e2964fe2b81f | |
parent | ccb7b790cdd11bccb8d2ad32654ec23a2f05b134 (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.6 6.5
Fixes: QTBUG-117379
Change-Id: Ibf979eff0efee2fd82eac1c5c20a1a8bbc2ef2e6
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-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 4d944bf..f0d5f67 100644 --- a/src/repparser/parser.g +++ b/src/repparser/parser.g @@ -900,9 +900,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" |