GH-1080: Treat enum name re-use across different enum types as an error

This commit is contained in:
Jon Siwek 2020-07-31 16:17:22 -07:00
parent 613b27eec7
commit 4a9567e04f
3 changed files with 44 additions and 1 deletions

View file

@ -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;
}