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

MOC 5.8 is confused about namespaces

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.8.0
    • Fix Version/s: 5.9
    • Component/s: Build tools: moc
    • Labels:
      None

      Description

      Hi guys.

      After upgrading from Qt 5.7.1 to 5.8 moc started to confuse namespaces and generate weird code. I reverted from using C++17 syntax for nested namespaces about which moc also complained, but I still get non-compilable results from MOC. The same exact code works in moc 5.7.1.

      Attaching moc-generated sources from versions 5.8 (broken), 5.7.1 (which works okay, even accepts C+17-style "namespace a::b::c") and complete source (g+ -E) for the moc.

      Those are the errors generated:

       MOC       build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc
      /usr/bin/moc-qt5 xefis/support/devices/ht16k33.h -o build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc
      g++ -fPIC -O4 -g -c -std=c++17 -Wall -Wall -Wextra -Wunused -Wunused-function -Wunused-label -Wnoexcept -fstrict-aliasing -Wstrict-aliasing=3 -fnothrow-opt -pedantic-errors -pthread -rdynamic -I. -Ilib -finline -funroll-loops -fomit-frame-pointer -DQT_NO_DEBUG -DCXXFLAGS='"-fPIC -O4 -g -c -std=c++17 -Wall -Wall -Wextra -Wunused -Wunused-function -Wunused-label -Wnoexcept -fstrict-aliasing -Wstrict-aliasing=3 -fnothrow-opt -pedantic-errors -pthread -rdynamic -I. -Ilib -finline -funroll-loops -fomit-frame-pointer"'  -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt -isystem /usr/include/qt/QtXml -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt -isystem /usr/include/qt/QtGui -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/include/qt -DXEFIS_ENABLE_ASSERT -E xefis/support/devices/ht16k33.h -o build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc.E
       C++       build/x86_64/mocs/xefis/support/devices/ht16k33.moc.o
      g++ -fPIC -O4 -g -c -std=c++17 -Wall -Wall -Wextra -Wunused -Wunused-function -Wunused-label -Wnoexcept -fstrict-aliasing -Wstrict-aliasing=3 -fnothrow-opt -pedantic-errors -pthread -rdynamic -I. -Ilib -finline -funroll-loops -fomit-frame-pointer -DQT_NO_DEBUG -DCXXFLAGS='"-fPIC -O4 -g -c -std=c++17 -Wall -Wall -Wextra -Wunused -Wunused-function -Wunused-label -Wnoexcept -fstrict-aliasing -Wstrict-aliasing=3 -fnothrow-opt -pedantic-errors -pthread -rdynamic -I. -Ilib -finline -funroll-loops -fomit-frame-pointer"'  -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt -isystem /usr/include/qt/QtXml -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt -isystem /usr/include/qt/QtGui -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/include/qt -DXEFIS_ENABLE_ASSERT build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc -o build/x86_64/mocs/xefis/support/devices/ht16k33.moc.o
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:72:17: error: 'si::units::xf' has not been declared
       void si::units::xf::HT16K33::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
                       ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: In function 'void qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:9: error: 'HT16K33' was not declared in this scope
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
               ^~~~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:9: note: suggested alternatives:
      In file included from build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:9:0:
      build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:39:7: note:   'xf::HT16K33'
       class HT16K33: public QObject
             ^~~~~~~
      build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:39:7: note:   'xf::HT16K33'
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:18: error: '_t' was not declared in this scope
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
                        ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:35: error: 'HT16K33' does not name a type
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
                                         ^~~~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:43: error: expected '>' before '*' token
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
                                                 ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:43: error: expected '(' before '*' token
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:44: error: expected primary-expression before '>' token
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
                                                  ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:75:49: error: expected ')' before ';' token
               HT16K33 *_t = static_cast<HT16K33 *>(_o);
                                                       ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: At global scope:
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:87:30: error: 'si::units::xf' has not been declared
       const QMetaObject si::units::xf::HT16K33::staticMetaObject = {
                                    ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:93:31: error: 'si::units::xf' has not been declared
       const QMetaObject *si::units::xf::HT16K33::metaObject() const
                                     ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:93:57: error: non-member function 'const QMetaObject* metaObject()' cannot have cv-qualifier
       const QMetaObject *si::units::xf::HT16K33::metaObject() const
                                                               ^~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: In function 'const QMetaObject* metaObject()':
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:95:21: error: 'QScopedPointer<QObjectData> QObject::d_ptr' is protected within this context
           return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
                           ^~~~~
      In file included from /usr/include/qt/QtCore/QObject:1:0,
                       from build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:24,
                       from build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:9:
      /usr/include/qt/QtCore/qobject.h:423:33: note: declared protected here
           QScopedPointer<QObjectData> d_ptr;
                                       ^~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:95:21: error: invalid use of non-static data member 'QObject::d_ptr'
           return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
                           ^~~~~
      In file included from /usr/include/qt/QtCore/QObject:1:0,
                       from build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:24,
                       from build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:9:
      /usr/include/qt/QtCore/qobject.h:423:33: note: declared here
           QScopedPointer<QObjectData> d_ptr;
                                       ^~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:95:50: error: 'QScopedPointer<QObjectData> QObject::d_ptr' is protected within this context
           return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
                                                        ^~~~~
      In file included from /usr/include/qt/QtCore/QObject:1:0,
                       from build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:24,
                       from build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:9:
      /usr/include/qt/QtCore/qobject.h:423:33: note: declared protected here
           QScopedPointer<QObjectData> d_ptr;
                                       ^~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:95:50: error: invalid use of non-static data member 'QObject::d_ptr'
           return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
                                                        ^~~~~
      In file included from /usr/include/qt/QtCore/QObject:1:0,
                       from build/x86_64/mocs/xefis/support/devices/../../../../../../xefis/support/devices/ht16k33.h:24,
                       from build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:9:
      /usr/include/qt/QtCore/qobject.h:423:33: note: declared here
           QScopedPointer<QObjectData> d_ptr;
                                       ^~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: At global scope:
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:98:18: error: 'si::units::xf' has not been declared
       void *si::units::xf::HT16K33::qt_metacast(const char *_clname)
                        ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: In function 'void* qt_metacast(const char*)':
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:47: error: 'HT16K33' does not name a type
               return static_cast<void*>(const_cast< HT16K33*>(this));
                                                     ^~~~~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:54: error: expected '>' before '*' token
               return static_cast<void*>(const_cast< HT16K33*>(this));
                                                            ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:54: error: expected '(' before '*' token
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:55: error: expected primary-expression before '>' token
               return static_cast<void*>(const_cast< HT16K33*>(this));
                                                             ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:57: error: invalid use of 'this' in non-member function
               return static_cast<void*>(const_cast< HT16K33*>(this));
                                                               ^~~~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:102:63: error: expected ')' before ';' token
               return static_cast<void*>(const_cast< HT16K33*>(this));
                                                                     ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:103:40: error: cannot call member function 'virtual void* QObject::qt_metacast(const char*)' without object
           return QObject::qt_metacast(_clname);
                                              ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: At global scope:
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:106:16: error: 'si::units::xf' has not been declared
       int si::units::xf::HT16K33::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
                      ^~
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc: In function 'int qt_metacall(QMetaObject::Call, int, void**)':
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:108:43: error: cannot call member function 'virtual int QObject::qt_metacall(QMetaObject::Call, int, void**)' without object
           _id = QObject::qt_metacall(_c, _id, _a);
                                                 ^
      build/x86_64/mocs/xefis/support/devices/ht16k33.moc.cc:113:32: error: invalid use of 'this' in non-member function
                   qt_static_metacall(this, _c, _id, _a);
                                      ^~~~
      make[2]: *** [Makefile:280: build/x86_64/mocs/xefis/support/devices/ht16k33.moc.o] Error 1

        Attachments

        1. ht16k33.h
          12 kB
        2. ht16k33.moc__qt-5.7.1.cc
          4 kB
        3. ht16k33.moc__qt-5.8.0.cc
          4 kB
        4. ht16k33.moc.cc.E
          4.21 MB
        For Gerrit Dashboard: QTBUG-59351
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            ogoffart Olivier Goffart (Woboq GmbH)
            Reporter:
            mcv Michał Gawron
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes