From 12fd0c683884fab3a728d39002476d2412ce3339 Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Wed, 18 Jan 2017 09:59:13 -0800 Subject: [PATCH] GenEnum: bit_flags: Remove useless conditions (#4141) The conditions to add the "NONE" or "ANY" value in the enum were useless because the user cannot provide a zero value or a bitmask (for "ANY") in the bit_flags enum type. --- src/idl_gen_cpp.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 587bb86af..329e28a2f 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -525,16 +525,13 @@ class CppGenerator : public BaseGenerator { code_.SetValue("SEP", ",\n"); if (enum_def.attributes.Lookup("bit_flags")) { - if (minv->value != 0) { // If the user didn't defined NONE value - code_.SetValue("KEY", GenEnumValDecl(enum_def, "NONE")); - code_.SetValue("VALUE", "0"); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - } - if (maxv->value != anyv) { // If the user didn't defined ANY value - code_.SetValue("KEY", GenEnumValDecl(enum_def, "ANY")); - code_.SetValue("VALUE", NumToString(anyv)); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - } + code_.SetValue("KEY", GenEnumValDecl(enum_def, "NONE")); + code_.SetValue("VALUE", "0"); + code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; + + code_.SetValue("KEY", GenEnumValDecl(enum_def, "ANY")); + code_.SetValue("VALUE", NumToString(anyv)); + code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; } else { // MIN & MAX are useless for bit_flags code_.SetValue("KEY",GenEnumValDecl(enum_def, "MIN")); code_.SetValue("VALUE", GenEnumValDecl(enum_def, minv->name));