]> granicus.if.org Git - icinga2/commitdiff
Fix compiler warnings in auto-generated code.
authorGunnar Beutner <gunnar@beutner.name>
Fri, 8 Nov 2013 20:45:27 +0000 (21:45 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 8 Nov 2013 20:45:27 +0000 (21:45 +0100)
Refs #5036

tools/mkclass/classcompiler.cpp

index 9b750b3b1911e28d857110683bcdd6532d070807..28892309ed4b3c63155c827163255c98b3eaa9ae 100644 (file)
@@ -168,25 +168,31 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
                std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
                << "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
 
-       std::cout << "\t\t" << "switch (";
+       if (klass.Fields.size() > 0) {
+               std::cout << "\t\t" << "switch (";
 
-       if (!klass.Parent.empty())
-               std::cout << "real_id";
-       else
-               std::cout << "id";
+               if (!klass.Parent.empty())
+                       std::cout << "real_id";
+               else
+                       std::cout << "id";
 
-       std::cout << ") {" << std::endl;
+               std::cout << ") {" << std::endl;
 
-       num = 0;
-       for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-               std::cout << "\t\t\t" << "case " << num << ":" << std::endl
-                       << "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
-               num++;
+               num = 0;
+               for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
+                       std::cout << "\t\t\t" << "case " << num << ":" << std::endl
+                               << "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
+                       num++;
+               }
+
+               std::cout << "\t\t\t" << "default:" << std::endl
+                                 << "\t\t";
        }
 
-       std::cout << "\t\t\t" << "default:" << std::endl
-               << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
-               << "\t\t" << "}" << std::endl;
+       std::cout << "\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl;
+
+       if (klass.Fields.size() > 0)
+               std::cout << "\t\t" << "}" << std::endl;
 
        std::cout << "\t" << "}" << std::endl << std::endl;