Skip to content

Commit

Permalink
moc: handle attributes in class declarations
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
  • Loading branch information
Inkane committed Aug 3, 2022
1 parent d5580aa commit 84ab6c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/tools/moc/moc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/tools/moc/cxx-attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 84ab6c1

Please sign in to comment.