aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Savoundararadj <savoundg@gmail.com>2017-01-18 09:59:13 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2017-01-18 09:59:13 -0800
commit12fd0c683884fab3a728d39002476d2412ce3339 (patch)
tree98a5941dab07ded0b19d29c22106089e04a044c9
parent19101826a80b415680738cf3722ee02a0b0c8565 (diff)
downloadflatbuffers-12fd0c683884fab3a728d39002476d2412ce3339.tar.gz
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.
-rw-r--r--src/idl_gen_cpp.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index 587bb86a..329e28a2 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));