]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/82550 (program using submodules fails to link)
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 29 Dec 2018 18:21:39 +0000 (18:21 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 29 Dec 2018 18:21:39 +0000 (18:21 +0000)
2018-12-29  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'.

2018-12-29  Paul Thomas  <pault@gcc.gnu.org>

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

From-SVN: r267466

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

index 40d64bd4cc156b1ff0dcf4ae9e2ca7980a29056d..e12b57709616840a7490721ec32d5bd60d2f990f 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from trunk
+       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'.
+
 2018-12-23  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from trunk
index 1e2be2f2d0ebac069fb86a79f2de913276e8deb9..f0a2e03ecf25bf4712ca8a802b20c9f7028e892d 100644 (file)
@@ -1655,7 +1655,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 81f74eb2645b49cb443c33538da721066d9eb0be..a366259c3e08dfc05fc86781272d6aad69daf21c 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/82550
+       * gfortran.dg/submodule_30.f08 : New test.
+
 2018-12-24  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline
@@ -10,7 +16,7 @@
 
        Backport from mainline
        2018-08-16  Iain Sandoe <iain@sandoe.co.uk>
+
        * g++.dg/torture/pr44295.C : Skip for Darwin.
 
 2018-12-24  Iain Sandoe  <iain@sandoe.co.uk>
@@ -23,7 +29,7 @@
        (test_noreturn): Likewise.
 
        2018-08-16  Iain Sandoe <iain@sandoe.co.uk>
+
        * gcc.dg/memcmp-1.c (lib_memcmp): Apply __USER_LABEL_PREFIX__.
        (lib_strncmp): Likewise.
 
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..7d59bab
--- /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'
+     STOP 1
+  end if
+end program p_18_pos
+