Skip to content
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

[flang] Identify misparsed statement function in BLOCK in ASSOCIATE #72148

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

klausler
Copy link
Contributor

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.

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.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Nov 13, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 13, 2023

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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

@klausler klausler merged commit c3148e9 into llvm:main Nov 14, 2023
5 checks passed
@klausler klausler deleted the l3a branch November 14, 2023 00:37
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…lvm#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants