aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/resolve.cc5
-rw-r--r--gcc/testsuite/gfortran.dg/pr104571.f9012
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 2907677..21c8797 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -2397,8 +2397,9 @@ resolve_elemental_actual (gfc_expr *expr, gfc_code *c)
if (rank > 0 && esym && expr == NULL)
for (eformal = esym->formal, arg = arg0; arg && eformal;
arg = arg->next, eformal = eformal->next)
- if ((eformal->sym->attr.intent == INTENT_OUT
- || eformal->sym->attr.intent == INTENT_INOUT)
+ if (eformal->sym
+ && (eformal->sym->attr.intent == INTENT_OUT
+ || eformal->sym->attr.intent == INTENT_INOUT)
&& arg->expr && arg->expr->rank == 0)
{
gfc_error ("Actual argument at %L for INTENT(%s) dummy %qs of "
diff --git a/gcc/testsuite/gfortran.dg/pr104571.f90 b/gcc/testsuite/gfortran.dg/pr104571.f90
new file mode 100644
index 0000000..9a6f2d0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr104571.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
+! PR fortran/104571 - ICE in resolve_elemental_actual
+! Contributed by G.Steinmetz
+
+program p
+ real :: x(3)
+ call g(x) ! { dg-error "Missing alternate return" }
+contains
+ elemental subroutine g(*) ! { dg-error "Alternate return specifier" }
+ end
+end