[flang-commits] [flang] [flang] Identify misparsed statement function in BLOCK in ASSOCIATE (PR #72148)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Nov 13 10:37:58 PST 2023
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 68eb9987c0cbc8f1ec02050378dd53764125cb95 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 13 Nov 2023 10:35:12 -0800
Subject: [PATCH] [flang] Identify misparsed statement function in BLOCK in
ASSOCIATE
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.
---
flang/lib/Semantics/resolve-names.cpp | 1 +
flang/test/Semantics/blockconstruct01.f90 | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 98773a1b9d6ab45..9e96551943aeb23 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3496,6 +3496,7 @@ bool SubprogramVisitor::HandleStmtFunction(const parser::StmtFunctionStmt &x) {
if (auto *symbol{FindSymbol(name)}) {
Symbol &ultimate{symbol->GetUltimate()};
if (ultimate.has<ObjectEntityDetails>() ||
+ ultimate.has<AssocEntityDetails>() ||
CouldBeDataPointerValuedFunction(&ultimate)) {
misparsedStmtFuncFound_ = true;
return false;
diff --git a/flang/test/Semantics/blockconstruct01.f90 b/flang/test/Semantics/blockconstruct01.f90
index 3b0a343b15d5162..ebe441cad187c58 100644
--- a/flang/test/Semantics/blockconstruct01.f90
+++ b/flang/test/Semantics/blockconstruct01.f90
@@ -64,3 +64,13 @@ subroutine s7_c1107
arr(x) = x - 1 ! ok
end block
end
+
+subroutine s8
+ real x(1)
+ associate (sf=>x)
+ block
+ integer :: j = 1
+ sf(j) = j ! looks like a statement function, but isn't one
+ end block
+ end associate
+end
More information about the flang-commits
mailing list