[flang] Prevent crash in error case: elemental with alternate return
authorPeter Klausler <pklausler@nvidia.com>
Fri, 16 Dec 2022 23:10:50 +0000 (15:10 -0800)
committerPeter Klausler <pklausler@nvidia.com>
Sat, 17 Dec 2022 00:45:51 +0000 (16:45 -0800)
When an ELEMENTAL subroutine is erroneously declared with alternate return
arguments, don't crash when checking the ranks of the actual arguments.

Differential Revision: https://reviews.llvm.org/D140143

flang/lib/Semantics/check-call.cpp

index 76cb96c..104ea7a 100644 (file)
@@ -891,7 +891,7 @@ static bool CheckElementalConformance(parser::ContextualMessages &messages,
   int index{0};
   bool hasArrayArg{false};
   for (const auto &arg : actuals) {
-    if (arg && arg.value().Rank() > 0) {
+    if (arg && !arg->isAlternateReturn() && arg->Rank() > 0) {
       hasArrayArg = true;
       break;
     }