public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string
@ 2016-08-24 12:07 Paul Richard Thomas
  2016-08-24 12:36 ` Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2016-08-24 12:07 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Damian Rouson

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

Dear All,

The attached fixes this problem, bootstraps and regtests on FC21/x86_64.

OK for 6-branch and trunk?

Paul

2016-08-24  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/77358

    * resolve.c (resolve_fl_procedure): Use the correct gfc_charlen
    for deferred character length module procedures.

2016-08-24  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/77358
    * gfortran.dg/submodule_17.f08: New test.

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

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c	(revision 238840)
--- gcc/fortran/resolve.c	(working copy)
*************** resolve_fl_procedure (gfc_symbol *sym, i
*** 11961,11966 ****
--- 11961,11973 ----
        iface = sym->ts.interface;
        sym->ts.interface = NULL;
  
+       /* Make sure that the result uses the correct charlen for deferred
+ 	 length results.  */
+       if (iface && sym->result
+ 	  && iface->ts.type == BT_CHARACTER
+ 	  && iface->ts.deferred)
+ 	sym->result->ts.u.cl = iface->ts.u.cl;
+ 
        if (iface == NULL)
  	goto check_formal;
  
Index: gcc/testsuite/gfortran.dg/submodule_17.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_17.f08	(revision 0)
--- gcc/testsuite/gfortran.dg/submodule_17.f08	(working copy)
***************
*** 0 ****
--- 1,27 ----
+ ! { dg-do run }
+ !
+ ! Tests the fix for PR77358, in which the wrong gfc_charlen was
+ ! being used for the result of 'get'.
+ !
+ ! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
+ !
+ module hello_interface
+   character(len=13) :: string="Hello, world!"
+   interface
+     module function get() result(result_string)
+       character(:), allocatable :: result_string
+     end function
+   end interface
+ end module
+ 
+ submodule(hello_interface) hello_implementation
+ contains
+   module function get() result(result_string)
+     character(:), allocatable :: result_string
+     result_string = string
+   end function
+ end submodule
+ 
+   use hello_interface
+   if (get() .ne. string) call abort
+ end

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string
  2016-08-24 12:07 [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string Paul Richard Thomas
@ 2016-08-24 12:36 ` Tobias Burnus
  2016-08-24 19:41   ` Paul Richard Thomas
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2016-08-24 12:36 UTC (permalink / raw)
  To: gcc-patches, fortran, Paul Richard Thomas, Damian Rouson

Dear Paul,

Paul Richard Thomas wrote:
> The attached fixes this problem, bootstraps and regtests on FC21/x86_64.
> OK for 6-branch and trunk?

Looks good to me. Thanks for the patch.

Tobias

> 2016-08-24  Paul Thomas  <pault@gcc.gnu.org>
> 
>     PR fortran/77358
> 
>     * resolve.c (resolve_fl_procedure): Use the correct gfc_charlen

There shouldn't be a space between the PR line and the rest.
> 
>     PR fortran/77358
>     * gfortran.dg/submodule_17.f08: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string
  2016-08-24 12:36 ` Tobias Burnus
@ 2016-08-24 19:41   ` Paul Richard Thomas
  2016-08-24 19:47     ` Paul Richard Thomas
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2016-08-24 19:41 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran, Damian Rouson

Dear Tobias,

Committed to trunk as revision 239740. 6-branch to follow.

Thanks for the review.

Best regards

Paul

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string
  2016-08-24 19:41   ` Paul Richard Thomas
@ 2016-08-24 19:47     ` Paul Richard Thomas
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2016-08-24 19:47 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran, Damian Rouson

...and to 6-branch as revision 239741.

Cheers

Paul

On 24 August 2016 at 21:41, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Dear Tobias,
>
> Committed to trunk as revision 239740. 6-branch to follow.
>
> Thanks for the review.
>
> Best regards
>
> Paul



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-24 19:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 12:07 [Patch, fortran] pr77358 - [F08] deferred-length character function returns zero-length string Paul Richard Thomas
2016-08-24 12:36 ` Tobias Burnus
2016-08-24 19:41   ` Paul Richard Thomas
2016-08-24 19:47     ` 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).