Skip to content

[flang] Fix bogus error on statement function #89402

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
Apr 22, 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
2 changes: 1 addition & 1 deletion flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ bool SubprogramVisitor::HandleStmtFunction(const parser::StmtFunctionStmt &x) {
misparsedStmtFuncFound_ = true;
return false;
}
if (DoesScopeContain(&ultimate.owner(), currScope())) {
if (IsHostAssociated(*symbol, currScope())) {
if (context().ShouldWarn(
common::LanguageFeature::StatementFunctionExtensions)) {
Say(name,
Expand Down
15 changes: 13 additions & 2 deletions flang/test/Semantics/stmt-func02.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
module m
module m1
contains
real function rf2(x)
rf2 = x
end
end
module m2
use m1
real, target :: x = 1.
contains
function rpf(x)
Expand All @@ -18,7 +25,11 @@ subroutine test1
end
subroutine test2
!PORTABILITY: Name 'rf' from host scope should have a type declaration before its local statement function definition
rf(x) = 3.
rf(x) = 1.
end
subroutine test2b
!PORTABILITY: Name 'rf2' from host scope should have a type declaration before its local statement function definition
rf2(x) = 1.
end
subroutine test3
external sf
Expand Down
Loading