diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2017-03-11 14:49:57 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2017-03-11 14:49:57 +0000 |
commit | c08de9db47cea407e4399c987d2b8b9b6a6413ed (patch) | |
tree | 0c0816499c2d1669fe279e6c7c3afde3190d275d /libgfortran/io/unit.c | |
parent | 85059a38cba2e84d0242f5d0b835ab95ad4b4965 (diff) | |
download | gcc-c08de9db47cea407e4399c987d2b8b9b6a6413ed.zip gcc-c08de9db47cea407e4399c987d2b8b9b6a6413ed.tar.gz gcc-c08de9db47cea407e4399c987d2b8b9b6a6413ed.tar.bz2 |
re PR fortran/78854 ([F03] DTIO namelist output not working on internal unit)
2017-03-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/78854
* io/list_read.c (nml_get_obj_data): Stash internal unit for
later use by child procedures.
* io/write.c (nml_write_obj): Likewise.
* io/tranfer.c (data_transfer_init): Minor whitespace.
* io/unit.c (set_internal_uit): Look for the stashed internal
unit and use it if found.
* gfortran.dg/dtio_25.f90: New test.
From-SVN: r246070
Diffstat (limited to 'libgfortran/io/unit.c')
-rw-r--r-- | libgfortran/io/unit.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index ed3bc32..b733b93 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -461,6 +461,7 @@ set_internal_unit (st_parameter_dt *dtp, gfc_unit *iunit, int kind) { gfc_offset start_record = 0; + iunit->unit_number = dtp->common.unit; iunit->recl = dtp->internal_unit_len; iunit->internal_unit = dtp->internal_unit; iunit->internal_unit_len = dtp->internal_unit_len; @@ -598,15 +599,28 @@ get_unit (st_parameter_dt *dtp, int do_create) return unit; } } + + /* If an internal unit number is passed from the parent to the child + it should have been stashed on the newunit_stack ready to be used. + Check for it now and return the internal unit if found. */ + if (newunit_tos && (dtp->common.unit <= NEWUNIT_START) + && (dtp->common.unit == newunit_stack[newunit_tos].unit_number)) + { + unit = newunit_stack[newunit_tos--].unit; + return unit; + } + /* Has to be an external unit. */ dtp->u.p.unit_is_internal = 0; dtp->internal_unit = NULL; dtp->internal_unit_desc = NULL; + /* For an external unit with unit number < 0 creating it on the fly is not allowed, such units must be created with OPEN(NEWUNIT=...). */ if (dtp->common.unit < 0) return get_gfc_unit (dtp->common.unit, 0); + return get_gfc_unit (dtp->common.unit, do_create); } |