Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75637

moc adds extra semicolon to Q_UNUSED

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12
    • Build tools: moc
    • None

    Description

      moc adds an extra semicolon to Q_UNUSED.

      moc this code:

      class MyQObject : public QObject
      {
          Q_OBJECT
      };
      

      current moc output:

      ...
      void MyQObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
      {
          Q_UNUSED(_o);
          Q_UNUSED(_id);
          Q_UNUSED(_c);
          Q_UNUSED(_a);
      }
      ...
      

      expected moc output:

      ...
      void MyQObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
      {
          Q_UNUSED(_o)
          Q_UNUSED(_id)
          Q_UNUSED(_c)
          Q_UNUSED(_a)
      }
      ...
      

      Q_UNUSED expands to #define Q_UNUSED( x ) (void)x;, so the semicolon added by moc is superfluous.
      This triggers a compiler warning: -Wextra-semi-stmt

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            tobiasludwig Tobias Ludwig
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes