* [Patch, fortran] PR82550 - program using submodules fails to link
@ 2017-10-17 18:33 Paul Richard Thomas
2017-10-18 0:52 ` Jerry DeLisle
0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2017-10-17 18:33 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 603 bytes --]
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?
Paul
2017-10-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82550
* expr.c (gfc_check_pointer_assign): A use associated procedure
target in a submodule must have the 'use_assoc' attribute set
so that the name mangling is done correctly.
2017-10-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82550
* gfortran.dg/submodule_30.f08 : New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 2018 bytes --]
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c (revision 253748)
--- gcc/fortran/expr.c (working copy)
*************** gfc_check_pointer_assign (gfc_expr *lval
*** 3632,3637 ****
--- 3632,3645 ----
name = s2->name;
}
+ /* Make the procedure use associated so that the middle end does
+ the right thing with name mangling. This undoes the reset in
+ parse.c(set_syms_host_assoc) and is necessary to allow the
+ attributes of module procedure interfaces to be changed. */
+ if (s2 && s2->attr.flavor == FL_PROCEDURE
+ && s2->module && s2->attr.used_in_submodule)
+ s2->attr.use_assoc = 1;
+
if (s2 && s2->attr.proc_pointer && s2->ts.interface)
s2 = s2->ts.interface;
Index: gcc/testsuite/gfortran.dg/submodule_30.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_30.f08 (nonexistent)
--- 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
+
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR82550 - program using submodules fails to link
2017-10-17 18:33 [Patch, fortran] PR82550 - program using submodules fails to link Paul Richard Thomas
@ 2017-10-18 0:52 ` Jerry DeLisle
2017-10-18 8:58 ` Paul Richard Thomas
0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2017-10-18 0:52 UTC (permalink / raw)
To: Paul Richard Thomas, fortran, gcc-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR82550 - program using submodules fails to link
2017-10-18 0:52 ` Jerry DeLisle
@ 2017-10-18 8:58 ` Paul Richard Thomas
0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2017-10-18 8:58 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: fortran, gcc-patches
[-- 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
+
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-18 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17 18:33 [Patch, fortran] PR82550 - program using submodules fails to link Paul Richard Thomas
2017-10-18 0:52 ` Jerry DeLisle
2017-10-18 8:58 ` Paul Richard Thomas
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).