Fortran] PR93309 – permit repeated 'implicit none(external)'
authorTobias Burnus <tobias@codesourcery.com>
Tue, 21 Jan 2020 12:42:11 +0000 (13:42 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 21 Jan 2020 12:42:11 +0000 (13:42 +0100)
        PR fortran/93309
        * interface.c (gfc_procedure_use): Also check parent namespace for
        'implict none (external)'.
        * symbol.c (gfc_get_namespace): Don't set has_implicit_none_export
        to parent namespace's setting.

        PR fortran/93309
        * gfortran.dg/external_implicit_none_2.f90: New.

gcc/fortran/ChangeLog
gcc/fortran/interface.c
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/external_implicit_none_2.f90 [new file with mode: 0644]

index 3f412fd8c20be8c79802468c47f98b82bbed3e44..8d963a56b66208a2fd6fc5671b6caa86e6f61380 100644 (file)
@@ -1,3 +1,11 @@
+2020-01-21  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93309
+       * interface.c (gfc_procedure_use): Also check parent namespace for
+       'implict none (external)'.
+       * symbol.c (gfc_get_namespace): Don't set has_implicit_none_export
+       to parent namespace's setting. 
+
 2020-01-19  Thomas König  <tkoenig@gcc.gnu.org>
 
        PR fortran/44960
index c4a6882533b232c398b7e8478c11c35a37e15350..429abc79ca2e41b04a62d9e4c7741a2a3bab6f2f 100644 (file)
@@ -3798,8 +3798,16 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
      explicitly declared at all if requested.  */
   if (sym->attr.if_source == IFSRC_UNKNOWN && !sym->attr.is_iso_c)
     {
+      bool has_implicit_none_export = false;
       implicit = true;
-      if (sym->ns->has_implicit_none_export && sym->attr.proc == PROC_UNKNOWN)
+      if (sym->attr.proc == PROC_UNKNOWN)
+       for (gfc_namespace *ns = sym->ns; ns; ns = ns->parent)
+         if (ns->has_implicit_none_export)
+           {
+             has_implicit_none_export = true;
+             break;
+           }
+      if (has_implicit_none_export)
        {
          const char *guessed
            = gfc_lookup_function_fuzzy (sym->name, sym->ns->sym_root);
index 526f6c466b3189e3f3e0b79c24db8f587b5abcc0..47b716454f24320f806fb4577a193a554eaefdb7 100644 (file)
@@ -2898,9 +2898,6 @@ gfc_get_namespace (gfc_namespace *parent, int parent_types)
        }
     }
 
-  if (parent_types && ns->parent != NULL)
-    ns->has_implicit_none_export = ns->parent->has_implicit_none_export;
-
   ns->refs = 1;
 
   return ns;
index 6332af819aa7489c20c835894bf508cd19f9d2dd..806e0b90441d239c2d692780023f7544afac346b 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-21  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93309
+       * gfortran.dg/external_implicit_none_2.f90: New.
+
 2020-01-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92328
diff --git a/gcc/testsuite/gfortran.dg/external_implicit_none_2.f90 b/gcc/testsuite/gfortran.dg/external_implicit_none_2.f90
new file mode 100644 (file)
index 0000000..b2b1dd1
--- /dev/null
@@ -0,0 +1,28 @@
+! { dg-do compile }
+!
+! PR fortran/93309
+!
+module m
+  implicit none(external)
+contains
+  subroutine s
+    implicit none(external) ! OK
+  end subroutine
+end module
+
+module m2
+  implicit none(external)
+contains
+  subroutine s
+    call foo(1)  ! { dg-error "not explicitly declared" }
+  end subroutine
+end module
+
+module m3
+  implicit none(external)
+contains
+  subroutine s
+    implicit none(external) ! OK
+    implicit none(external) ! { dg-error "Duplicate IMPLICIT NONE statement" }
+  end subroutine
+end module