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] |
The following patch implements an extension/enhancement of my original __buitin_memcpy patch that was suggested/recommended by Paul Thomas. This extends the set of types considered "copyable" with memcpy to additionally include user derived types that don't contain allocatable components. This allows us to use memcpy in the following testcase. type t logical valid integer :: x, y end type type (t) :: s(5) type (t) :: d(5) d(:) = s(:) The trick is to use the same logic as in gfc_trans_scalar_assign, and check the ts.derived->alloc_comp field, which indicates whether the type contains any allocatable fields that require special handling. Presumably, the front-end sets this field correctly for derived types containing derived types, otherwise both the existing gfc_trans_scalar_assign and the new code below contain potential bugs. Likewise, for derived types containing character fields. Presuming that the existing code is sound, the patch below simply tweaks the recent copyable_array_p predicate to also handle BT_DERIVED. Tested on x86_64-unknown-linux-gnu with a full "make bootstrap", including gfortran, and regression tested with a top-level "make -k check" with no new failures. Ok for mainline? 2007-01-17 Roger Sayle <roger@eyesopen.com> * trans-expr.c (copyable_array_p): Consider user derived type without allocatable components to be copyable. * gfortran.dg/array_memcpy_4.f90: New test case. Roger --
Attachment:
patchf4.txt
Description: Text document
Attachment:
array_memcpy_4.f90
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |