Skip to content

Commit c3148e9

Browse files
authored
[flang] Identify misparsed statement function in BLOCK in ASSOCIATE (llvm#72148)
When a BLOCK construct is within an ASSOCIATE or related construct, don't misinterpret an assignment to an array element of a construct entity as being an impermissible definition of a local statement function.
1 parent 86c57b9 commit c3148e9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,6 +3507,7 @@ bool SubprogramVisitor::HandleStmtFunction(const parser::StmtFunctionStmt &x) {
35073507
if (auto *symbol{FindSymbol(name)}) {
35083508
Symbol &ultimate{symbol->GetUltimate()};
35093509
if (ultimate.has<ObjectEntityDetails>() ||
3510+
ultimate.has<AssocEntityDetails>() ||
35103511
CouldBeDataPointerValuedFunction(&ultimate)) {
35113512
misparsedStmtFuncFound_ = true;
35123513
return false;

flang/test/Semantics/blockconstruct01.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ subroutine s7_c1107
6464
arr(x) = x - 1 ! ok
6565
end block
6666
end
67+
68+
subroutine s8
69+
real x(1)
70+
associate (sf=>x)
71+
block
72+
integer :: j = 1
73+
sf(j) = j ! looks like a statement function, but isn't one
74+
end block
75+
end associate
76+
end

0 commit comments

Comments
 (0)