mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
GH-1080: Treat enum name re-use across different enum types as an error
This commit is contained in:
parent
613b27eec7
commit
4a9567e04f
3 changed files with 44 additions and 1 deletions
|
@ -1270,9 +1270,14 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
|||
string fullname = make_full_var_name(module_name.c_str(), name);
|
||||
if ( id->Name() != fullname
|
||||
|| (id->HasVal() && val != id->GetVal()->AsEnum())
|
||||
|| GetName() != id->GetType()->GetName()
|
||||
|| (names.find(fullname) != names.end() && names[fullname] != val) )
|
||||
{
|
||||
reporter->Error("identifier or enumerator value in enumerated type definition already exists");
|
||||
auto cl = detail::GetCurrentLocation();
|
||||
reporter->PushLocation(&cl, id->GetLocationInfo());
|
||||
reporter->Error("conflicting definition of enum value '%s' in type '%s'",
|
||||
fullname.data(), GetName().data());
|
||||
reporter->PopLocation();
|
||||
SetError();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue