* [patch, fortran] Bug 81296 - derived type I/o problem
@ 2017-08-21 7:51 Jerry DeLisle
2017-08-21 12:56 ` Paul Richard Thomas
0 siblings, 1 reply; 2+ messages in thread
From: Jerry DeLisle @ 2017-08-21 7:51 UTC (permalink / raw)
To: fortran; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 499 bytes --]
Hi all,
The attached patch adds a check for the format label containing a "DT" format
descriptor and enables the generation of the correct code. The patch modifies
an existing test case as a future check on this.
Regression tested on x86_64-linux.
OK for trunk and backport to 7?
Regards,
Jerry
2017-08-21 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/81296
* trans-io.c (get_dtio_proc): Add check for format label and set
formatted flag accordingly. Reorganize the code a little.
[-- Attachment #2: pr81296.diff --]
[-- Type: text/x-patch, Size: 1718 bytes --]
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index c3c56f29..aa974eb3 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -2214,18 +2214,24 @@ get_dtio_proc (gfc_typespec * ts, gfc_code * code, gfc_symbol **dtio_sub)
bool formatted = false;
gfc_dt *dt = code->ext.dt;
- if (dt && dt->format_expr)
+ if (dt)
{
- char *fmt;
- fmt = gfc_widechar_to_char (dt->format_expr->value.character.string,
- -1);
- if (strtok (fmt, "DT") != NULL)
+ char *fmt = NULL;
+
+ if (dt->format_label == &format_asterisk)
+ {
+ /* List directed io must call the formatted DTIO procedure. */
+ formatted = true;
+ }
+ else if (dt->format_expr)
+ fmt = gfc_widechar_to_char (dt->format_expr->value.character.string,
+ -1);
+ else if (dt->format_label)
+ fmt = gfc_widechar_to_char (dt->format_label->format->value.character.string,
+ -1);
+ if (fmt && strtok (fmt, "DT") != NULL)
formatted = true;
- }
- else if (dt && dt->format_label == &format_asterisk)
- {
- /* List directed io must call the formatted DTIO procedure. */
- formatted = true;
+
}
if (ts->type == BT_CLASS)
diff --git a/gcc/testsuite/gfortran.dg/dtio_12.f90 b/gcc/testsuite/gfortran.dg/dtio_12.f90
index 213f7ebb..cf1bfe38 100644
--- a/gcc/testsuite/gfortran.dg/dtio_12.f90
+++ b/gcc/testsuite/gfortran.dg/dtio_12.f90
@@ -70,5 +70,11 @@ end module
rewind (10)
read (10, *) msg
if (trim (msg) .ne. "77") call abort
+ rewind (10)
+ write (10,40) child (77) ! Modified using format label
+40 format(DT)
+ rewind (10)
+ read (10, *) msg
+ if (trim (msg) .ne. "77") call abort
close(10)
end
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch, fortran] Bug 81296 - derived type I/o problem
2017-08-21 7:51 [patch, fortran] Bug 81296 - derived type I/o problem Jerry DeLisle
@ 2017-08-21 12:56 ` Paul Richard Thomas
0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2017-08-21 12:56 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: fortran, GCC Patches
Hi Jerry,
That looks good to me - OK for trunk and for backporting.
Thanks for the patch.
Paul
PS Did you have time to think about that rather more difficult bug,
involving a mix of DT descriptors and intrinsic descriptors for the
declared type?
On 21 August 2017 at 03:23, Jerry DeLisle <jvdelisle@charter.net> wrote:
> Hi all,
>
> The attached patch adds a check for the format label containing a "DT"
> format descriptor and enables the generation of the correct code. The patch
> modifies an existing test case as a future check on this.
>
> Regression tested on x86_64-linux.
>
> OK for trunk and backport to 7?
>
> Regards,
>
> Jerry
>
> 2017-08-21 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR fortran/81296
> * trans-io.c (get_dtio_proc): Add check for format label and set
> formatted flag accordingly. Reorganize the code a little.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-21 12:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 7:51 [patch, fortran] Bug 81296 - derived type I/o problem Jerry DeLisle
2017-08-21 12:56 ` 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).