moc: handle attributes in class declarations

We already had code to handle attributes on funtcions, but we didn't
handle them correctly for classes so far.
Fix this by simply skipping over the attribute.

Fixes: QTBUG-105310
Pick-to: 5.15 6.2 6.3 6.4
Change-Id: Ic4149f940e74820de4f2fa9540d9dc5b4e626a3a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Fabian Kosmale 2022-08-03 09:16:27 +02:00
parent d5580aa719
commit 84ab6c1aa1
2 changed files with 4 additions and 1 deletions

View File

@ -40,6 +40,9 @@ bool Moc::parseClassHead(ClassDef *def)
return false;
} while (token);
// support attributes like "class [[deprecated]]] name"
skipCxxAttributes();
if (!test(IDENTIFIER)) // typedef struct { ... }
return false;
QByteArray name = lexem();

View File

@ -10,7 +10,7 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunknown-attributes")
QT_WARNING_DISABLE_GCC("-Wattributes")
class CppAttribute : public QObject
class [[deprecated]] CppAttribute : public QObject
{
Q_OBJECT
signals: