|| (p->next == NULL && q->next != NULL))
arg_count_mismatch = true;
else if ((p->sym == NULL && q->sym == NULL)
- || strcmp (p->sym->name, q->sym->name) == 0)
+ || (p->sym && q->sym
+ && strcmp (p->sym->name, q->sym->name) == 0))
continue;
else
- gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
- "argument names (%s/%s) at %C",
- p->sym->name, q->sym->name);
+ {
+ if (q->sym == NULL)
+ gfc_error_now ("MODULE PROCEDURE formal argument %qs "
+ "conflicts with alternate return at %C",
+ p->sym->name);
+ else if (p->sym == NULL)
+ gfc_error_now ("MODULE PROCEDURE formal argument is "
+ "alternate return and conflicts with "
+ "%qs in the separate declaration at %C",
+ q->sym->name);
+ else
+ gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
+ "argument names (%s/%s) at %C",
+ p->sym->name, q->sym->name);
+ }
}
if (arg_count_mismatch)
--- /dev/null
+! { dg-do compile }
+! { dg-options "-w" }
+! PR fortran/104649
+! Contributed by G.Steinmetz
+
+module m
+ interface
+ module subroutine s(x)
+ real :: x
+ end
+ end interface
+end
+submodule(m) m2
+contains
+ module subroutine s(*) ! { dg-error "conflicts with alternate return" }
+ end
+end
+
+module n
+ interface
+ module subroutine s(*)
+ end
+ end interface
+end
+submodule(n) n2
+contains
+ module subroutine s(x) ! { dg-error "formal argument is alternate return" }
+ real :: x
+ end
+end
+
+module p
+ interface
+ module subroutine s(x)
+ real :: x
+ end
+ end interface
+end
+submodule(p) p2
+contains
+ module subroutine s(y) ! { dg-error "Mismatch in MODULE PROCEDURE formal argument names" }
+ real :: y
+ end
+end