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

via flang-commits flang-commits at lists.llvm.org
Mon Nov 13 16:37:22 PST 2023


Author: Peter Klausler
Date: 2023-11-13T16:37:18-08:00
New Revision: c3148e9f693b41fb52f8ffe940cb1390bc027e0f

URL: https://github.com/llvm/llvm-project/commit/c3148e9f693b41fb52f8ffe940cb1390bc027e0f
DIFF: https://github.com/llvm/llvm-project/commit/c3148e9f693b41fb52f8ffe940cb1390bc027e0f.diff

LOG: [flang] Identify misparsed statement function in BLOCK in ASSOCIATE (#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.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp
    flang/test/Semantics/blockconstruct01.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 9b3c0eb8ba93192..8f15f2f51da7c89 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3507,6 +3507,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