Skip to content

Commit 92ecc22

Browse files
authored
[flang] Fix crash in semantics on bad program (#87199)
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.
1 parent eeedb1e commit 92ecc22

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8525,7 +8525,9 @@ void ResolveNamesVisitor::AnalyzeStmtFunctionStmt(
85258525
Symbol *symbol{name.symbol};
85268526
auto *details{symbol ? symbol->detailsIf<SubprogramDetails>() : nullptr};
85278527
if (!details || !symbol->scope() ||
8528-
&symbol->scope()->parent() != &currScope()) {
8528+
&symbol->scope()->parent() != &currScope() || details->isInterface() ||
8529+
details->isDummy() || details->entryScope() ||
8530+
details->moduleInterface() || symbol->test(Symbol::Flag::Subroutine)) {
85298531
return; // error recovery
85308532
}
85318533
// Resolve the symbols on the RHS of the statement function.

0 commit comments

Comments
 (0)