public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: Jerry DeLisle <jvdelisle@charter.net>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch, fortran] PR82550 - program using submodules fails to link
Date: Wed, 18 Oct 2017 08:58:00 -0000	[thread overview]
Message-ID: <CAGkQGiKZE-mt1HHtVn5yhU0DHEG=UXZz4aahkN+kVqXW=UCLrw@mail.gmail.com> (raw)
In-Reply-To: <cd35a4dd-27c4-6ce8-85ba-6574d30ecbf5@charter.net>

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]

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

[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 2257 bytes --]

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
+ 

      reply	other threads:[~2017-10-18  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 18:33 Paul Richard Thomas
2017-10-18  0:52 ` Jerry DeLisle
2017-10-18  8:58   ` Paul Richard Thomas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGkQGiKZE-mt1HHtVn5yhU0DHEG=UXZz4aahkN+kVqXW=UCLrw@mail.gmail.com' \
    --to=paul.richard.thomas@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jvdelisle@charter.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).