From: Jerry DeLisle Date: Tue, 22 Aug 2017 01:02:15 +0000 (+0000) Subject: re PR fortran/81296 (derived type I/o problem) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bef016bff7ed63c87dedfcdeac0e00653de3565a;p=gcc.git re PR fortran/81296 (derived type I/o problem) 2017-08-21 Jerry DeLisle PR fortran/81296 * trans-io.c (get_dtio_proc): Add check for format label and set formatted flag accordingly. Reorganize the code a little. * gfortran.dg/dtio_12.f90: Update test. From-SVN: r251254 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4a572cfb4ae..1b2b4c93753 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-08-21 Jerry DeLisle + + PR fortran/81296 + * trans-io.c (get_dtio_proc): Add check for format label and set + formatted flag accordingly. Reorganize the code a little. + 2017-08-16 Thomas Koenig PR fortran/81116 diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index c3c56f29623..aa974eb3805 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/ChangeLog b/gcc/testsuite/ChangeLog index b3466cdf7af..ed19baca404 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-21 Jerry DeLisle + + PR fortran/81296 + * gfortran.dg/dtio_12.f90: Update test. + 2017-08-21 Nathan Sidwell * g++.dg/template/pr81899.C: Fix c++03. diff --git a/gcc/testsuite/gfortran.dg/dtio_12.f90 b/gcc/testsuite/gfortran.dg/dtio_12.f90 index 213f7ebbb1e..cf1bfe38e2f 100644 --- a/gcc/testsuite/gfortran.dg/dtio_12.f90 +++ b/gcc/testsuite/gfortran.dg/dtio_12.f90 @@ -67,6 +67,12 @@ end module if (trim (msg) .ne. "42") call abort rewind (10) write (10,"(DT)") child (77) ! The original testcase + 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