diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-08-03 09:16:27 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-08-03 20:14:42 +0200 |
commit | 84ab6c1aa1fe4051edb9f96714f0f691d639b725 (patch) | |
tree | c08374c3e2902b90e68870db7fba9d966f152497 | |
parent | d5580aa7194b84306da52efb189cf126dbaee1f7 (diff) | |
download | qtbase-84ab6c1aa1fe4051edb9f96714f0f691d639b725.tar.gz |
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>
-rw-r--r-- | src/tools/moc/moc.cpp | 3 | ||||
-rw-r--r-- | tests/auto/tools/moc/cxx-attributes.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 8a5abd3020..5e2ba18a00 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -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(); diff --git a/tests/auto/tools/moc/cxx-attributes.h b/tests/auto/tools/moc/cxx-attributes.h index 799a13293c..6301d7804c 100644 --- a/tests/auto/tools/moc/cxx-attributes.h +++ b/tests/auto/tools/moc/cxx-attributes.h @@ -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: |