diff mbox

[fortran] Implement inquire(iolength= ) for DTIO

Message ID b52503f9-5bea-b32f-6de2-26c4f23c7cae@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Oct. 15, 2016, 7:07 p.m. UTC
This very simple patch implements the subject feature.

Fortran Standard draft F2016 states in 9.10.3.2:

The output list in an INQUIRE statement shall not contain any derived-type list 
items that require a defined input/output procedure as described in subclause 
9.6.3. If a derived-type list item appears in the output list, the value 
returned for the IOLENGTH= specifier assumes that no defined input/output 
procedure will be invoked.

The language seems a little obscure. I think the first sentence means don't 
expect inquire to use a UDDTIO procedure and the second sentence says when you 
use a derived type that has UDDTIO procedures in the output list, treat them as 
if they don't and use the default derived type lengths.

Regression tested on x86-64-linux. New test case attached.

I will give this a day or two for comment.

OK for trunk.

Jerry

2016-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* trans-io.c (transfer_expr): Ignore dtio procedures for inquire
	with iolength.

2016-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* gfortran.dg/dtio_16.f90: New test.
diff mbox

Patch

diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 3cdbf1fd..216317ad 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -2325,7 +2325,7 @@  transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr,
           if (derived->attr.has_dtio_procs)
             arg2 = get_dtio_proc (ts, code, &dtio_sub);

-         if (dtio_sub != NULL)
+         if ((dtio_sub != NULL) && (last_dt != IOLENGTH))
             {
               tree decl;
               decl = build_fold_indirect_ref_loc (input_location,