]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran] PR93309 – permit repeated 'implicit none(external)'
authorTobias Burnus <tobias@codesourcery.com>
Mon, 3 Feb 2020 10:48:17 +0000 (11:48 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Mon, 3 Feb 2020 10:48:17 +0000 (11:48 +0100)
Backported from mainline
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.

Backported from mainline
2020-01-21  Tobias Burnus  <tobias@codesourcery.com>

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 e0a34420e362db09f6de7ae69a7417356f19ff0e..ec87cc9e6cf6d4be42735dfa98aab8dbdcdfc6e8 100644 (file)
@@ -1,3 +1,14 @@
+2020-02-03  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from mainline
+       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-22  Jakub Jelinek  <jakub@redhat.com>
 
        * parse.c (parse_omp_structured_block): Handle ST_OMP_TARGET_PARALLEL.
@@ -10,7 +21,7 @@
 
 2020-01-17  Mark Eggleston  <mark.eggleston@codethink.com>
 
-        Backport from mainline
+       Backport from mainline
        Mark Eggleston  <mark.eggleston@codethink.com>
 
        PR fortran/93236
index bee98129bc1b5680b67e9ab2ec89fe15dfa8aaf3..b5701b1a59a1f7074ab7e2843550eed734813903 100644 (file)
@@ -3671,7 +3671,12 @@ 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)
     {
-      if (sym->ns->has_implicit_none_export && sym->attr.proc == PROC_UNKNOWN)
+      bool has_implicit_none_export = false;
+      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;
+      if (has_implicit_none_export)
        {
          const char *guessed
            = gfc_lookup_function_fuzzy (sym->name, sym->ns->sym_root);
index 2b8f86e0881f30bd1334c32655b33903a971eee0..faaeebf2c0989542ed0886f075395465c131c668 100644 (file)
@@ -2899,9 +2899,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 9e117a6854a18cbaf80625c8d0604e4afbe20076..0f8e75926659463e6961eb0d711303591e8a5b77 100644 (file)
@@ -1,3 +1,11 @@
+2020-02-03  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from mainline
+       2020-01-21  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93309
+       * gfortran.dg/external_implicit_none_2.f90: New.
+
 2020-01-30  Kito Cheng  <kito.cheng@sifive.com>
 
        Backport from mainline
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