Skip to content

Conversation

@klausler
Copy link
Contributor

Don't accept a putative statement function definition for a symbol that is a subprogram but can't possibly be a statement function.

Fixes #86936.

Don't accept a putative statement function definition for a symbol
that is a subprogram but can't possibly be a statement function.

Fixes llvm#86936.
@llvmbot
Copy link
Member

llvmbot commented Mar 31, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

Don't accept a putative statement function definition for a symbol that is a subprogram but can't possibly be a statement function.

Fixes #86936.


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

1 Files Affected:

  • (modified) flang/lib/Semantics/resolve-names.cpp (+3-1)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 2e88a2daff2c08..f2db329e30be78 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8525,7 +8525,9 @@ void ResolveNamesVisitor::AnalyzeStmtFunctionStmt(
   Symbol *symbol{name.symbol};
   auto *details{symbol ? symbol->detailsIf<SubprogramDetails>() : nullptr};
   if (!details || !symbol->scope() ||
-      &symbol->scope()->parent() != &currScope()) {
+      &symbol->scope()->parent() != &currScope() || details->isInterface() ||
+      details->isDummy() || details->entryScope() ||
+      details->moduleInterface() || symbol->test(Symbol::Flag::Subroutine)) {
     return; // error recovery
   }
   // Resolve the symbols on the RHS of the statement function.

@klausler klausler merged commit 92ecc22 into llvm:main Apr 8, 2024
@klausler klausler deleted the bug86936 branch April 8, 2024 18:53
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.

[Flang] fatal internal error: CHECK(isFunction()) failed at /root/llvm-project/flang/include/flang/Semantics/symbol.h(190)

3 participants