ENUMERATOR declarations are checking for conflicts between new
enumerator names and names in both the local scope and scopes
that contain it. ENUMERATOR declarations belong to the local
scope and so only a conflict with a name therein is an error.
(In short, use FindInScope rather than FindSymbol.)
Differential Revision: https://reviews.llvm.org/D142773
bool DeclarationVisitor::Pre(const parser::Enumerator &enumerator) {
const parser::Name &name{std::get<parser::NamedConstant>(enumerator.t).v};
- Symbol *symbol{FindSymbol(name)};
+ Symbol *symbol{FindInScope(name)};
if (symbol && !symbol->has<UnknownDetails>()) {
// Contrary to named constants appearing in a PARAMETER statement,
// enumerator names should not have their type, dimension or any other