diff --git a/src/Type.cc b/src/Type.cc index 3dd649167b..2343cfdfe9 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1341,6 +1341,9 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, bro_int_t val, bool is_export, detail::Expr* deprecation, bool from_redef) { + if ( from_redef ) + has_redefs = true; + if ( Lookup(val) ) { reporter->Error("enumerator value in enumerated type definition already exists"); diff --git a/src/Type.h b/src/Type.h index bbcd00f7a5..5ff7330e8c 100644 --- a/src/Type.h +++ b/src/Type.h @@ -722,12 +722,15 @@ public: // -1 indicates not found. bro_int_t Lookup(const std::string& module_name, const char* name) const; + const char* Lookup(bro_int_t value) const; // Returns 0 if not found // Returns the list of defined names with their values. The names // will be fully qualified with their module name. enum_name_list Names() const; + bool HasRedefs() const { return has_redefs; } + void Describe(ODesc* d) const override; void DescribeReST(ODesc* d, bool roles_only = false) const override; @@ -747,6 +750,9 @@ protected: typedef std::map NameMap; NameMap names; + // Whether any of the elements of the enum were added via redef's. + bool has_redefs = false; + using ValMap = std::unordered_map; ValMap vals;