We already disallow them for classes; this was a mistake in not handling
the "struct" keyword. The C++ syntax is valid, but moc is unable to
parse two classes at the same time. Users can define the inner outside
of the body of the outer class and that works.
[ChangeLog][moc] Fixed a bug that caused moc to attempt to parse a
nested struct (not class) with meta keywords and this produced code that
wouldn't compile. Nested classes and structures are permitted, but must
be defined outside of the declaration of the outer class.
The fix for this revealed a bug in the presence of Q_DECLARE_FLAGS for
inner classes. This can be easily fixed by moving the token for
Q_DECLARE_FLAGS value outside of the [Q_META_TOKEN_BEGIN,
Q_META_TOKEN_END] range.
[ChangeLog][moc] Fixed a bug that caused moc to reject a class (not
struct) containing Q_DECLARE_FLAGS that was defined inside the body of
an outer class containing Q_OBJECT or Q_GADGET.
Fixes: QTBUG-130498
Pick-to: 6.5
Change-Id: I2a3f148f70280e87302afffd3e7617e5861bb338
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 4e4eef175bc0d0e2a34875ae98f2ddf9eee73b35)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>