[flang-commits] [flang] [flang] Identify misparsed statement function in BLOCK in ASSOCIATE (PR #72148)

via flang-commits flang-commits at lists.llvm.org
Mon Nov 13 10:38:32 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/72148.diff


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-names.cpp (+1) 
- (modified) flang/test/Semantics/blockconstruct01.f90 (+10) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/72148


More information about the flang-commits mailing list