summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-07-11 12:25:21 +0200
committerUlf Hermann <ulf.hermann@qt.io>2016-07-12 10:02:44 +0000
commitc18f33846a522deb6569f3ddf2343f4a750025f6 (patch)
treef616b04320d6914828666af30a1eb525709f6de4 /tools
parent55169920b69378d61da3cc9dc60e0b583f47909c (diff)
Avoid compile warnings about empty switch statements
MSVC 2015 doesn't like switch statements with nothing but a default clause. Change-Id: Iddce723fef54b61ae52d9256160c2fc44844bd0b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qscxmlc/data.t4
-rw-r--r--tools/qscxmlc/scxmlcppdumper.cpp11
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/qscxmlc/data.t b/tools/qscxmlc/data.t
index a1eece5..c9150de 100644
--- a/tools/qscxmlc/data.t
+++ b/tools/qscxmlc/data.t
@@ -69,9 +69,7 @@ ${classname}::~${classname}()
QScxmlInvokableServiceFactory *${classname}::Data::serviceFactory(int id) const
{
- switch (id) {
- ${serviceFactories}
- }
+${serviceFactories}
}
std::vector<QString> ${classname}::Data::outgoingEvents = {
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp
index d261b22..3446e4d 100644
--- a/tools/qscxmlc/scxmlcppdumper.cpp
+++ b/tools/qscxmlc/scxmlcppdumper.cpp
@@ -626,8 +626,15 @@ void CppDumper::writeImplBody(const GeneratedTableData &table,
name = QStringLiteral("string(%1)").arg(table.theName);
}
- QString serviceFactories = factory.join(QStringLiteral("\n "))
- + QStringLiteral("\n default: Q_UNREACHABLE();");
+ QString serviceFactories;
+ if (factory.isEmpty()) {
+ serviceFactories = QStringLiteral(" Q_UNUSED(id);\n Q_UNREACHABLE();");
+ } else {
+ serviceFactories = QStringLiteral(" switch (id) {\n ")
+ + factory.join(QStringLiteral("\n "))
+ + QStringLiteral("\n default: Q_UNREACHABLE();\n }");
+ }
+
Replacements r;
r[QStringLiteral("classname")] = className;