@@ -1552,6 +1552,12 @@ match_actual_arg (gfc_expr **result)
sym = symtree->n.sym;
gfc_set_sym_referenced (sym);
+ if (sym->attr.flavor == FL_NAMELIST)
+ {
+ gfc_error ("Namelist '%s' can not be an argument at %L",
+ sym->name, &where);
+ break;
+ }
if (sym->attr.flavor != FL_PROCEDURE
&& sym->attr.flavor != FL_UNKNOWN)
break;
@@ -3219,6 +3225,10 @@ gfc_match_rvalue (gfc_expr **result)
m = gfc_match_actual_arglist (0, &e->value.function.actual);
break;
+ case FL_NAMELIST:
+ m = MATCH_ERROR;
+ break;
+
default:
gfc_error ("Symbol at %C is not appropriate for an expression");
return MATCH_ERROR;
@@ -14226,6 +14226,21 @@ resolve_symbol (gfc_symbol *sym)
break;
case FL_PROCEDURE:
+ if (sym->formal && !sym->formal_ns)
+ {
+ /* Check that none of the arguments are a namelist. */
+ gfc_formal_arglist *formal = sym->formal;
+
+ for (; formal; formal = formal->next)
+ if (formal->sym && formal->sym->attr.flavor == FL_NAMELIST)
+ {
+ gfc_error ("Namelist '%s' can not be an argument to "
+ "subroutine or function at %L",
+ formal->sym->name, &sym->declared_at);
+ return;
+ }
+ }
+
if (!resolve_fl_procedure (sym, mp_flag))
return;
break;
new file mode 100644
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options -std=gnu }
+! PR50555 synonymous namelist/statement function dummy argument not allowed
+subroutine g(k1, k2, k3)
+ integer, intent(in) :: k1, k2, k3
+ print *, k
+end subroutine
+function j(k1, k2, k3)
+ integer, intent(in) :: k1, k2, k3
+ j = 25 * k
+end function
+program pr50555
+ namelist /i/ j
+ call g(k,l,i) ! { dg-error "can not be an argument" }
+ f(k,l,i)=0 ! { dg-error "can not be an argument" }
+ h = j(k,l,i) ! { dg-error "can not be an argument" }
+end program
+! Note: -std=gnu needed because line 15 function statement is obsolescent