[Patch, fortran] PR82550 - program using submodules fails to link

Paul Richard Thomas paul.richard.thomas@gmail.com
Wed Oct 18 09:00:00 GMT 2017


Dear Jerry,

Thanks. I Committed as revision 253848 a still simpler patch that
achieves the same end. Please see the attached and the ChangeLogs
below.

Regards

Paul

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.

On 18 October 2017 at 01:52, Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 10/17/2017 11:33 AM, Paul Richard Thomas wrote:
>> The attached patch has a comment that explains what is going on.
>>
>> Bootstrapped and regtested on FC23/x86_64 - OK for trunk and 7-branch?
>>
>
> Yes, looks OK for both. Thanks.
>
> Jerry



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
-------------- next part --------------
Index: /home/pault/svn/trunk/gcc/fortran/trans-decl.c
===================================================================
*** /home/pault/svn/trunk/gcc/fortran/trans-decl.c	(revision 253748)
--- /home/pault/svn/trunk/gcc/fortran/trans-decl.c	(working copy)
*************** gfc_get_symbol_decl (gfc_symbol * sym)
*** 1670,1676 ****
      {
        /* Catch functions. Only used for actual parameters,
  	 procedure pointers and procptr initialization targets.  */
!       if (sym->attr.use_assoc || sym->attr.intrinsic
  	  || sym->attr.if_source != IFSRC_DECL)
  	{
  	  decl = gfc_get_extern_function_decl (sym);
--- 1670,1678 ----
      {
        /* Catch functions. Only used for actual parameters,
  	 procedure pointers and procptr initialization targets.  */
!       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: /home/pault/svn/trunk/gcc/testsuite/gfortran.dg/submodule_30.f08
===================================================================
*** /home/pault/svn/trunk/gcc/testsuite/gfortran.dg/submodule_30.f08	(nonexistent)
--- /home/pault/svn/trunk/gcc/testsuite/gfortran.dg/submodule_30.f08	(working copy)
***************
*** 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
+ 


More information about the Gcc-patches mailing list