From 4cbff97c4377b49517286cce3a60b6b28f5e969e Mon Sep 17 00:00:00 2001 From: Nikolay Kuznetsov Date: Mon, 25 Mar 2019 22:06:00 +0300 Subject: [PATCH] Fix a warning on compiling with clang (#5258) --- include/flatbuffers/reflection_generated.h | 2 +- samples/monster_generated.h | 4 ++-- src/idl_gen_cpp.cpp | 4 ++-- tests/monster_test_generated.h | 8 ++++---- tests/namespace_test/namespace_test1_generated.h | 2 +- tests/union_vector/union_vector_generated.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/flatbuffers/reflection_generated.h b/include/flatbuffers/reflection_generated.h index fc720599c..869a9f3f2 100644 --- a/include/flatbuffers/reflection_generated.h +++ b/include/flatbuffers/reflection_generated.h @@ -95,7 +95,7 @@ inline const char * const *EnumNamesBaseType() { inline const char *EnumNameBaseType(BaseType e) { if (e < None || e > Union) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesBaseType()[index]; } diff --git a/samples/monster_generated.h b/samples/monster_generated.h index 0f7d06460..84e816024 100644 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -59,7 +59,7 @@ inline const char * const *EnumNamesColor() { inline const char *EnumNameColor(Color e) { if (e < Color_Red || e > Color_Blue) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesColor()[index]; } @@ -89,7 +89,7 @@ inline const char * const *EnumNamesEquipment() { inline const char *EnumNameEquipment(Equipment e) { if (e < Equipment_NONE || e > Equipment_Weapon) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesEquipment()[index]; } diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 15b02156a..50cb82fab 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -1017,10 +1017,10 @@ class CppGenerator : public BaseGenerator { " || e > " + GetEnumValUse(enum_def, *enum_def.vals.vec.back()) + ") return \"\";"; - code_ += " const size_t index = static_cast(e)\\"; + code_ += " const size_t index = static_cast(e)\\"; if (enum_def.vals.vec.front()->value) { auto vals = GetEnumValUse(enum_def, *enum_def.vals.vec.front()); - code_ += " - static_cast(" + vals + ")\\"; + code_ += " - static_cast(" + vals + ")\\"; } code_ += ";"; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index 1285ba8ec..f98e86b71 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -133,7 +133,7 @@ inline const char * const *EnumNamesColor() { inline const char *EnumNameColor(Color e) { if (e < Color_Red || e > Color_Blue) return ""; - const size_t index = static_cast(e) - static_cast(Color_Red); + const size_t index = static_cast(e) - static_cast(Color_Red); return EnumNamesColor()[index]; } @@ -169,7 +169,7 @@ inline const char * const *EnumNamesAny() { inline const char *EnumNameAny(Any e) { if (e < Any_NONE || e > Any_MyGame_Example2_Monster) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesAny()[index]; } @@ -310,7 +310,7 @@ inline const char * const *EnumNamesAnyUniqueAliases() { inline const char *EnumNameAnyUniqueAliases(AnyUniqueAliases e) { if (e < AnyUniqueAliases_NONE || e > AnyUniqueAliases_M2) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesAnyUniqueAliases()[index]; } @@ -451,7 +451,7 @@ inline const char * const *EnumNamesAnyAmbiguousAliases() { inline const char *EnumNameAnyAmbiguousAliases(AnyAmbiguousAliases e) { if (e < AnyAmbiguousAliases_NONE || e > AnyAmbiguousAliases_M3) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesAnyAmbiguousAliases()[index]; } diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h index d26bf43e8..12b344d13 100644 --- a/tests/namespace_test/namespace_test1_generated.h +++ b/tests/namespace_test/namespace_test1_generated.h @@ -46,7 +46,7 @@ inline const char * const *EnumNamesEnumInNestedNS() { inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) { if (e < EnumInNestedNS_A || e > EnumInNestedNS_C) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesEnumInNestedNS()[index]; } diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h index 22c0217ea..962c98b91 100644 --- a/tests/union_vector/union_vector_generated.h +++ b/tests/union_vector/union_vector_generated.h @@ -74,7 +74,7 @@ inline const char * const *EnumNamesCharacter() { inline const char *EnumNameCharacter(Character e) { if (e < Character_NONE || e > Character_Unused) return ""; - const size_t index = static_cast(e); + const size_t index = static_cast(e); return EnumNamesCharacter()[index]; }