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] Fix crash in semantics on bad program #87199

Merged
merged 1 commit into from
Apr 8, 2024
Merged

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
Collaborator

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
7 checks passed
@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
3 participants