[flang-commits] [flang] 92ecc22 - [flang] Fix crash in semantics on bad program (#87199)

via flang-commits flang-commits at lists.llvm.org
Mon Apr 8 11:53:53 PDT 2024


Author: Peter Klausler
Date: 2024-04-08T11:53:49-07:00
New Revision: 92ecc22b8d18ad937053177533bd23c775556be6

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

LOG: [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 https://github.com/llvm/llvm-project/issues/86936.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


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


        


More information about the flang-commits mailing list