[Patch, fortran] Implement inquire(iolength= ) for DTIO

Jerry DeLisle jvdelisle@charter.net
Sat Oct 15 19:07:00 GMT 2016

This very simple patch implements the subject feature.

Fortran Standard draft F2016 states in

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.


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 --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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtio_16.f90
Type: text/x-fortran
Size: 2089 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161015/2bf7418b/attachment.bin>

More information about the Gcc-patches mailing list