This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fortran/patch to PR15364: support printing of array fields in derived types


On Monday 13 September 2004 15:17, Victor Leikehman wrote:
> Tested for regressions on linux/ia32.
>
> 2004-09-13  Victor Leikehman  <lei@il.ibm.com>
>
> 	Fix to PR/15364: support printing of array fields in derived types.
> 	* trans-io.c: (transfer_array_component) New function.
> 	(transfer_expr) For array fields, call transfer_array_component.


If I understand your patch correctly (you don't comment the
code much ;-), we now threat CHARACTER arrays:

*************** transfer_expr (gfc_se * se, gfc_typespec
*** 1193,1209 ****
          tmp = build3 (COMPONENT_REF, TREE_TYPE (field), expr, field,
                        NULL_TREE);
  
!         if (c->ts.type == BT_CHARACTER)
!           {
!             gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE);
!             se->string_length =
!               TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp)));
!           }
!         if (c->dimension)
!           gfc_todo_error ("IO of arrays in derived types");
!         if (!c->pointer)
!           tmp = gfc_build_addr_expr (NULL, tmp);
!         transfer_expr (se, &c->ts, tmp);
        }
        return;
  
--- 1277,1293 ----
          tmp = build3 (COMPONENT_REF, TREE_TYPE (field), expr, field,
                        NULL_TREE);
  
!           if (c->dimension)
!             {
!               tmp = transfer_array_component (tmp, c);
!               gfc_add_expr_to_block (&se->pre, tmp);
!             }
!           else
!             {
!               if (!c->pointer)
!                 tmp = gfc_build_addr_expr (NULL, tmp);
!               transfer_expr (se, &c->ts, tmp);
!             }
        }
        return;
  

I'm curious why this works, CHARACTER(len...) is not quite the same
as an array.

There really should be more comments in the code...  For example
transfer_array_component has no comments at all - not at the top
of the function as required by our coding style conventions, and
also not in the function body itself.  Please add an explanation
of what the function does.  There seem to be two distrinct things
going on there: (1) the initialization of ss, and (2) building a
loop to transfer the array component of the derived type.  Please
explain in the function what's going on there.

Your test cases could also use some less uninspired names ;-)

Gr.
Steven



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]