re PR fortran/82550 (program using submodules fails to link)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 18 Oct 2017 08:55:27 +0000 (08:55 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 18 Oct 2017 08:55:27 +0000 (08:55 +0000)
2017-10-18  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/82550
* trans_decl.c (gfc_get_symbol_decl): Procedure symbols that
have the 'used_in_submodule' attribute should be processed by
'gfc_get_extern_function_decl'.

2017-10-18  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/82550
* gfortran.dg/submodule_30.f08 : New test.

From-SVN: r253848

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/submodule_30.f08 [new file with mode: 0644]

index 02763fe580baf9aff8d7f0677931dca79fc12d4f..ab2665098791ee93549e0396aedc43a3d99c89b0 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-18  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/82550
+       * trans_decl.c (gfc_get_symbol_decl): Procedure symbols that
+       have the 'used_in_submodule' attribute should be processed by
+       'gfc_get_extern_function_decl'.
+
 2017-10-16  Fritz Reese <fritzoreese@gmail.com>
 
        PR fortran/82511
index 019b8035b6f4db98b28325a1056eb1a5b42093eb..c21611c5d6c874ce5715d8ab5bb9b42c638cf95a 100644 (file)
@@ -1670,7 +1670,9 @@ gfc_get_symbol_decl (gfc_symbol * sym)
     {
       /* Catch functions. Only used for actual parameters,
         procedure pointers and procptr initialization targets.  */
-      if (sym->attr.use_assoc || sym->attr.intrinsic
+      if (sym->attr.use_assoc
+         || sym->attr.used_in_submodule
+         || sym->attr.intrinsic
          || sym->attr.if_source != IFSRC_DECL)
        {
          decl = gfc_get_extern_function_decl (sym);
index bfb01971421d5cb9e546fc71fea53e2b3c0cb7f9..a43894f2ad65057094ced719bfbcff623d4db432 100644 (file)
@@ -1,3 +1,8 @@
+017-10-18  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/82550
+       * gfortran.dg/submodule_30.f08 : New test.
+
 2017-10-18  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * gcc.target/s390/zvector/vec-cmp-2.c
diff --git a/gcc/testsuite/gfortran.dg/submodule_30.f08 b/gcc/testsuite/gfortran.dg/submodule_30.f08
new file mode 100644 (file)
index 0000000..25dcbeb
--- /dev/null
@@ -0,0 +1,42 @@
+! { dg-do run }
+!
+! Test the fix for PR82550 in which the reference to 'p' in 'foo'
+! was not being correctly handled.
+!
+! Contributed by Reinhold Bader  <Bader@lrz.de>
+!
+module m_subm_18_pos
+  implicit none
+  integer :: i = 0
+  interface
+    module subroutine foo(fun_ptr)
+      procedure(p), pointer, intent(out) :: fun_ptr
+    end subroutine
+  end interface
+contains
+  subroutine p()
+    i = 1
+  end subroutine p
+end module m_subm_18_pos
+submodule (m_subm_18_pos) subm_18_pos
+    implicit none
+contains
+    module subroutine foo(fun_ptr)
+      procedure(p), pointer, intent(out) :: fun_ptr
+      fun_ptr => p
+    end subroutine
+end submodule
+program p_18_pos
+  use m_subm_18_pos
+  implicit none
+  procedure(), pointer :: x
+  call foo(x)
+  call x()
+  if (i == 1) then
+     write(*,*) 'OK'
+  else
+     write(*,*) 'FAIL'
+     call abort
+  end if
+end program p_18_pos
+