[flang] Fix regression from generic fix

A recent change that corrected the name resolution of a generic interface
when the same name was visible in scope incorrectly prevented a local
generic from shadowing an outer name that is not a generic, subprogram,
or derived type -- e.g., a simple variable -- leading to an inappropriate
error message.

Differential Revision: https://reviews.llvm.org/D124276
This commit is contained in:
Peter Klausler 2022-04-21 09:25:39 -07:00
parent ee285faed2
commit bf8f9b35c1
1 changed files with 11 additions and 9 deletions

View File

@ -6962,16 +6962,18 @@ void ResolveNamesVisitor::CreateGeneric(const parser::GenericSpec &x) {
info.Resolve(existing); info.Resolve(existing);
return; return;
} }
if (ultimate.has<SubprogramDetails>() || if (&existing->owner() == &currScope()) {
ultimate.has<SubprogramNameDetails>()) { if (ultimate.has<SubprogramDetails>() ||
genericDetails.set_specific(ultimate); ultimate.has<SubprogramNameDetails>()) {
} else if (ultimate.has<DerivedTypeDetails>()) { genericDetails.set_specific(ultimate);
genericDetails.set_derivedType(ultimate); } else if (ultimate.has<DerivedTypeDetails>()) {
} else { genericDetails.set_derivedType(ultimate);
SayAlreadyDeclared(symbolName, *existing); } else {
return; SayAlreadyDeclared(symbolName, *existing);
return;
}
EraseSymbol(*existing);
} }
EraseSymbol(*existing);
} }
info.Resolve(&MakeSymbol(symbolName, Attrs{}, std::move(genericDetails))); info.Resolve(&MakeSymbol(symbolName, Attrs{}, std::move(genericDetails)));
} }