[flang] Fix call to CHECK() on erroneous subroutine declaration

When processing declarations in resolve-names.cpp, we were returning a
symbol that had SubprogramName details to PushSubprogramScope(), which
expects a symbol with Subprogram details.

I adjusted the code and added a test.

Differential Revision: https://reviews.llvm.org/D89829
This commit is contained in:
Peter Steinfeld 2020-10-20 15:05:35 -07:00
parent 296314516d
commit 29d838310d
2 changed files with 13 additions and 1 deletions

View file

@ -3048,7 +3048,8 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
details->set_specific(Resolve(name, *specific));
} else if (isGeneric()) {
SayAlreadyDeclared(name, *specific);
} else if (!specific->has<SubprogramDetails>()) {
}
if (!specific->has<SubprogramDetails>()) {
specific->set_details(SubprogramDetails{});
}
return specific;

View file

@ -22,3 +22,14 @@ module m2
end subroutine
end interface
end module
module m3
interface s
subroutine s
end
end interface
contains
!ERROR: 's' is already declared in this scoping unit
subroutine s
end subroutine
end