https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109512

--- Comment #2 from kargl at gcc dot gnu.org ---
This patch catches the need for an external attribute.

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 6e42397c2ea..1e19712b413 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -3818,6 +3818,16 @@ resolve_call (gfc_code *c)
   /* Resume assumed_size checking.  */
   need_full_assumed_size--;

+  /* If 'implicit none (external)' and the symbol is a dummy argument,
+     check for an 'external' attribute.  */
+  if (csym->ns->has_implicit_none_export
+      && csym->attr.external == 0 && csym->attr.dummy == 1)
+    {
+      gfc_error ("Dummy procedure %qs at %C requires an EXTERNAL attribute",
+                csym->name);
+      return false;
+    }
+
   /* If external, check for usage.  */
   if (csym && is_external_proc (csym))
     resolve_global_procedure (csym, &c->loc, 1);

A dejagnu-ified testcase.

! { dg-do compile }
subroutine foo(bar)
  implicit none (external)
  call bar(1)        ! { dg-error "requires an EXTERNAL attribute" }
end subroutine foo

Reply via email to