Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.5.0
-
None
Description
If you declare a flag for a scoped enum using Q_FLAG(S) the genereated moc file causes a compiler error.
example class
class Foo : public QObject { Q_OBJECT public: enum Bar { BarA }; Q_ENUMS(Bar) Q_DECLARE_FLAGS(BarFlag, Bar) Q_FLAGS(BarFlag) enum class BarClass { A }; Q_ENUMS(BarClass) Q_DECLARE_FLAGS(BarClassFlag, BarClass) Q_FLAGS(BarClassFlag) };
moc generated code
// enum data: key, value
2, uint(Foo::BarA),
2, uint(Foo::BarA),
5, uint(Foo::BarClass::A),
5, uint(Foo::BarClassFlag::A),
compiler error GCC
moc_foo.cpp:69:16: error: 'A' is not a member of 'Foo::BarClassFlag {aka QFlags<Foo::BarClass>}' 5, uint(Foo::BarClassFlag::A), ^
compiler error Clang
moc_foo.cpp:69:35: error: no member named 'A' in 'QFlags<Foo::BarClass>' 5, uint(Foo::BarClassFlag::A), ~~~~~~~~~~~~~~~~~~~^