diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-12-09 08:38:57 +0100 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-12-15 13:24:29 +0000 |
commit | a5eabac96de54706de55497b16a46dc2223ac6e9 (patch) | |
tree | 0ff0503cc34cc2c479f9c6e18f258e1fdebd6fe3 /tests | |
parent | 41c1866d3e8d30dfc1e7b29123ff2b834e7489f7 (diff) | |
download | qtbase-a5eabac96de54706de55497b16a46dc2223ac6e9.tar.gz |
moc: add support for C++11 enum struct
C++11 added the new enum class key as well as enum struct. While the
former is likely the most known and used, the later can be used in the
same contexts and with the same effects.
Currently moc doesn't parse enum struct while it does for enum class.
This patch fixes this.
[ChangeLog][moc] moc now parses enum struct the same way as enum class
therefore that keyword can be used with the Q_ENUM macro as well as
Q_FLAG and Q_DECLARE_FLAGS.
Change-Id: Iaac3814ad63a15ee4d91b281d451e786b510449c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/moc/cxx11-enums.h | 9 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h index 93ab16c157..cc14c0acda 100644 --- a/tests/auto/tools/moc/cxx11-enums.h +++ b/tests/auto/tools/moc/cxx11-enums.h @@ -40,13 +40,22 @@ public: enum class TypedEnumClass : char { C0, C1, C2, C3 }; enum NormalEnum { D2 = 2, D3, D0 =0 , D1 }; enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8}; + + enum struct EnumStruct { G0, G1, G2, G3 }; + enum struct TypedEnumStruct : char { H0, H1, H2, H3 }; + enum struct StructFlag { I0 = 1, I1 = 2, I2 = 4, I3 = 8}; + Q_DECLARE_FLAGS(ClassFlags, ClassFlag) + Q_DECLARE_FLAGS(StructFlags, StructFlag) Q_ENUM(EnumClass) Q_ENUM(TypedEnum) Q_ENUM(TypedEnumClass) Q_ENUM(NormalEnum) + Q_ENUM(EnumStruct) + Q_ENUM(TypedEnumStruct) Q_FLAG(ClassFlags) + Q_FLAG(StructFlags) }; // Also test the Q_ENUMS macro diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 92a94055a4..293cbd8323 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2266,6 +2266,9 @@ void tst_Moc::cxx11Enums_data() QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false; QTest::newRow("ClassFlags") << meta1 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; QTest::newRow("ClassFlags 2") << meta2 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; + QTest::newRow("EnumStruct") << meta1 << QByteArray("EnumStruct") << QByteArray("EnumStruct") << 'G' << true; + QTest::newRow("TypedEnumStruct") << meta1 << QByteArray("TypedEnumStruct") << QByteArray("TypedEnumStruct") << 'H' << true; + QTest::newRow("StructFlags") << meta1 << QByteArray("StructFlags") << QByteArray("StructFlag") << 'I' << true; } void tst_Moc::cxx11Enums() |