diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2017-09-10 17:02:53 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2017-09-10 17:02:53 +0000 |
commit | ff3598bc73dbae3a612709daca41e56ab5aa6928 (patch) | |
tree | 83cec48b6de78db0f46a3c655690f575a6ab84ca /gcc/fortran/trans-types.c | |
parent | 7368cfa4986d83317fbfb839b1eeb249a9ef7199 (diff) | |
download | gcc-ff3598bc73dbae3a612709daca41e56ab5aa6928.zip gcc-ff3598bc73dbae3a612709daca41e56ab5aa6928.tar.gz gcc-ff3598bc73dbae3a612709daca41e56ab5aa6928.tar.bz2 |
re PR fortran/34640 (ICE when assigning item of a derived-component to a pointer)
2017-09-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34640
PR fortran/40737
PR fortran/55763
PR fortran/57019
PR fortran/57116
* expr.c (is_subref_array): Add class pointer array dummies
to the list of expressions that return true.
* trans-array.c: Add SPAN_FIELD and update indices for
subsequent fields.
(gfc_conv_descriptor_span, gfc_conv_descriptor_span_get,
gfc_conv_descriptor_span_set, is_pointer_array,
get_array_span): New functions.
(gfc_get_descriptor_offsets_for_info): New function to preserve
API for access to descriptor fields for trans-types.c.
(gfc_conv_scalarized_array_ref): If the expression is a subref
array, make sure that info->descriptor is a descriptor type.
Otherwise, if info->descriptor is a pointer array, set 'decl'
and fix it if it is a component reference.
(build_array_ref): Simplify handling of class array refs by
passing the vptr to gfc_build_array_ref rather than generating
the pointer arithmetic in this function.
(gfc_conv_array_ref): As in gfc_conv_scalarized_array_ref, set
'decl'.
(gfc_array_allocate): Set the span field if this is a pointer
array. Use the expr3 element size if it is available, so that
the dynamic type element size is used.
(gfc_conv_expr_descriptor): Set the span field for pointer
assignments.
* trans-array.h: Prototypes for gfc_conv_descriptor_span_get
gfc_conv_descriptor_span_set and
gfc_get_descriptor_offsets_for_info added.
trans-decl.c (gfc_get_symbol_decl): If a non-class pointer
array, mark the declaration as a GFC_DECL_PTR_ARRAY_P. Remove
the setting of GFC_DECL_SPAN.
(gfc_trans_deferred_vars): Set the span field to zero in thge
originating scope.
* trans-expr.c (gfc_conv_procedure_call): Do not use copy-in/
copy-out to pass subref expressions to a pointer dummy.
(gfc_trans_pointer_assignment): Remove code for setting of
GFC_DECL_SPAN. Set the 'span' field for non-class pointers to
class function results. Likewise for rank remap. In the case
that the target is not a whole array, use the target array ref
for remap and, since the 'start' indices are missing, set the
lbounds to one, as required by the standard.
* trans-intrinsic.c (conv_expr_ref_to_caf_ref): Pick up the
'token' offset from the field decl in the descriptor.
(conv_isocbinding_subroutine): Set the 'span' field.
* trans-io.c (gfc_trans_transfer): Always scalarize pointer
array io.
* trans-stmt.c (trans_associate_var): Set the 'span' field.
* trans-types.c (gfc_get_array_descriptor_base): Add the 'span'
field to the array descriptor.
(gfc_get_derived_type): Pointer array components are marked as
GFC_DECL_PTR_ARRAY_P.
(gfc_get_array_descr_info): Replaced API breaking code for
descriptor offset calling gfc_get_descriptor_offsets_for_info.
* trans.c (get_array_span): New function.
(gfc_build_array_ref): Simplify by calling get_array_span and
obtain 'span' if 'decl' or 'vptr' present.
* trans.h : Rename DECL_LANG_FLAG_6, GFC_DECL_SUBREF_ARRAY_P,
as GFC_DECL_PTR_ARRAY_P.
2017-09-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34640
* gfortran.dg/associate_24.f90: New test.
* gfortran.dg/assumed_type_2.f90: Adjust some of the tree dump
checks.
* gfortran.dg/no_arg_check_2.f90: Likewise.
* gfortran.dg/pointer_array_1.f90: New test.
* gfortran.dg/pointer_array_2.f90: New test.
* gfortran.dg/pointer_array_7.f90: New test.
* gfortran.dg/pointer_array_8.f90: New test.
* gfortran.dg/pointer_array_component_1.f90: New test.
* gfortran.dg/pointer_array_component_2.f90: New test.
* gfortran.dg/goacc/kernels-alias-4.f95: Bump up both tree scan
counts by 1.
PR fortran/40737
* gfortran.dg/pointer_array_3.f90: New test.
PR fortran/57116
* gfortran.dg/pointer_array_4.f90: New test.
PR fortran/55763
* gfortran.dg/pointer_array_5.f90: New test.
PR fortran/57019
* gfortran.dg/pointer_array_6.f90: New test.
2017-09-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34640
* libgfortran/libgfortran.h: Add span field to descriptor.
* libgfortran/libtool-version : Bump up version number to 5:0:0.
From-SVN: r251949
Diffstat (limited to 'gcc/fortran/trans-types.c')
-rw-r--r-- | gcc/fortran/trans-types.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 061222f..b106794 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" /* For rest_of_decl_compilation. */ #include "trans-types.h" #include "trans-const.h" +#include "trans-array.h" #include "dwarf2out.h" /* For struct array_descr_info. */ #include "attribs.h" @@ -1786,6 +1787,12 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) gfc_array_index_type, &chain); TREE_NO_WARNING (decl) = 1; + /* Add the span component. */ + decl = gfc_add_field_to_struct_1 (fat_type, + get_identifier ("span"), + gfc_array_index_type, &chain); + TREE_NO_WARNING (decl) = 1; + /* Build the array type for the stride and bound components. */ if (dimen + codimen > 0) { @@ -2715,6 +2722,11 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen) if (!c->backend_decl) c->backend_decl = field; + if (c->attr.pointer && c->attr.dimension + && !(c->ts.type == BT_DERIVED + && strcmp (c->name, "_data") == 0)) + GFC_DECL_PTR_ARRAY_P (c->backend_decl) = 1; + /* Do not add a caf_token field for classes' data components. */ if (codimen && !c->attr.dimension && !c->attr.codimension && (c->attr.allocatable || c->attr.pointer) @@ -3154,7 +3166,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) { int rank, dim; bool indirect = false; - tree etype, ptype, field, t, base_decl; + tree etype, ptype, t, base_decl; tree data_off, dim_off, dtype_off, dim_size, elem_size; tree lower_suboff, upper_suboff, stride_suboff; @@ -3211,24 +3223,11 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) if (indirect) base_decl = build1 (INDIRECT_REF, ptype, base_decl); - if (GFC_TYPE_ARRAY_SPAN (type)) - elem_size = GFC_TYPE_ARRAY_SPAN (type); - else - elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype)); - field = TYPE_FIELDS (TYPE_MAIN_VARIANT (type)); - data_off = byte_position (field); - field = DECL_CHAIN (field); - field = DECL_CHAIN (field); - dtype_off = byte_position (field); - field = DECL_CHAIN (field); - dim_off = byte_position (field); - dim_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (field))); - field = TYPE_FIELDS (TREE_TYPE (TREE_TYPE (field))); - stride_suboff = byte_position (field); - field = DECL_CHAIN (field); - lower_suboff = byte_position (field); - field = DECL_CHAIN (field); - upper_suboff = byte_position (field); + elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype)); + + gfc_get_descriptor_offsets_for_info (type, &data_off, &dtype_off, &dim_off, + &dim_size, &stride_suboff, + &lower_suboff, &upper_suboff); t = base_decl; if (!integer_zerop (data_off)) |