Skip to content

[flang] Fix type inheritance for statement function dummy arguments #93624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3694,10 +3694,8 @@ bool SubprogramVisitor::HandleStmtFunction(const parser::StmtFunctionStmt &x) {
for (const auto &dummyName : std::get<std::list<parser::Name>>(x.t)) {
ObjectEntityDetails dummyDetails{true};
if (auto *dummySymbol{FindInScope(currScope().parent(), dummyName)}) {
if (auto *d{dummySymbol->detailsIf<EntityDetails>()}) {
if (d->type()) {
dummyDetails.set_type(*d->type());
}
if (auto *d{dummySymbol->GetType()}) {
dummyDetails.set_type(*d);
}
}
Symbol &dummy{MakeSymbol(dummyName, std::move(dummyDetails))};
Expand Down
10 changes: 8 additions & 2 deletions flang/test/Semantics/stmt-func01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ pure integer function ifunc()
!ERROR: Statement function 'sf10' may not reference another statement function 'sf11' that is defined later
sf10(n) = sf11(n)
sf11(n) = sf10(n) ! mutual recursion, caused crash
sf13 = 1.
integer(1) iarg1
!PORTABILITY: nonstandard usage: based POINTER
pointer(iarg1p, iarg1)
sf13(iarg1) = iarg1
! executable part
print *, sf13(iarg1) ! ok
sf14 = 1.
contains
real function explicit(x,y)
integer, intent(in) :: x
Expand All @@ -50,7 +56,7 @@ pure function arr()
end function
subroutine foo
!PORTABILITY: An implicitly typed statement function should not appear when the same symbol is available in its host scope
sf13(x) = 2.*x
sf14(x) = 2.*x
end subroutine
end

Expand Down
Loading