Blame SOURCES/gcc8-pr92775.patch

cbc3fd
2020-03-30  Jakub Jelinek  <jakub@redhat.com>
cbc3fd
cbc3fd
	Backported from mainline
cbc3fd
	2019-12-06  Jakub Jelinek  <jakub@redhat.com>
cbc3fd
cbc3fd
	PR fortran/92775
cbc3fd
	* trans.h (struct lang_type, struct lang_decl): Remove span member.
cbc3fd
	(GFC_DECL_SPAN, GFC_TYPE_ARRAY_SPAN): Remove macros.
cbc3fd
	* trans-array.h (gfc_get_descriptor_offsets_for_info): Add another
cbc3fd
	argument.
cbc3fd
	* trans-array.c (gfc_get_descriptor_offsets_for_info): Add SPAN_OFF
cbc3fd
	argument and initialize *SPAN_OFF to the offset of span field.
cbc3fd
	* trans-types.c (gfc_get_array_descr_info): Adjust
cbc3fd
	gfc_get_descriptor_offsets_for_info caller.  Compute elem_size
cbc3fd
	as base->span instead of TYPE_SIZE_UNIT (etype) constant.
cbc3fd
cbc3fd
--- gcc/fortran/trans-array.c
cbc3fd
+++ gcc/fortran/trans-array.c
cbc3fd
@@ -503,9 +503,10 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc,
cbc3fd
 
cbc3fd
 void
cbc3fd
 gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
cbc3fd
-				     tree *dtype_off, tree *dim_off,
cbc3fd
-				     tree *dim_size, tree *stride_suboff,
cbc3fd
-				     tree *lower_suboff, tree *upper_suboff)
cbc3fd
+				     tree *dtype_off, tree *span_off,
cbc3fd
+				     tree *dim_off, tree *dim_size,
cbc3fd
+				     tree *stride_suboff, tree *lower_suboff,
cbc3fd
+				     tree *upper_suboff)
cbc3fd
 {
cbc3fd
   tree field;
cbc3fd
   tree type;
cbc3fd
@@ -515,6 +516,8 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
cbc3fd
   *data_off = byte_position (field);
cbc3fd
   field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD);
cbc3fd
   *dtype_off = byte_position (field);
cbc3fd
+  field = gfc_advance_chain (TYPE_FIELDS (type), SPAN_FIELD);
cbc3fd
+  *span_off = byte_position (field);
cbc3fd
   field = gfc_advance_chain (TYPE_FIELDS (type), DIMENSION_FIELD);
cbc3fd
   *dim_off = byte_position (field);
cbc3fd
   type = TREE_TYPE (TREE_TYPE (field));
cbc3fd
--- gcc/fortran/trans-array.h
cbc3fd
+++ gcc/fortran/trans-array.h
cbc3fd
@@ -159,7 +159,7 @@ void gfc_trans_array_cobounds (tree, stmtblock_t *, const gfc_symbol *);
cbc3fd
 
cbc3fd
 /* Build expressions for accessing components of an array descriptor.  */
cbc3fd
 void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *, tree *,
cbc3fd
-					  tree *, tree *, tree *);
cbc3fd
+					  tree *, tree *, tree *, tree *);
cbc3fd
 
cbc3fd
 tree gfc_conv_descriptor_data_get (tree);
cbc3fd
 tree gfc_conv_descriptor_data_addr (tree);
cbc3fd
--- gcc/fortran/trans-types.c
cbc3fd
+++ gcc/fortran/trans-types.c
cbc3fd
@@ -3344,7 +3344,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
cbc3fd
   int rank, dim;
cbc3fd
   bool indirect = false;
cbc3fd
   tree etype, ptype, t, base_decl;
cbc3fd
-  tree data_off, dim_off, dtype_off, dim_size, elem_size;
cbc3fd
+  tree data_off, span_off, dim_off, dtype_off, dim_size, elem_size;
cbc3fd
   tree lower_suboff, upper_suboff, stride_suboff;
cbc3fd
   tree dtype, field, rank_off;
cbc3fd
 
cbc3fd
@@ -3401,12 +3401,13 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
cbc3fd
   if (indirect)
cbc3fd
     base_decl = build1 (INDIRECT_REF, ptype, base_decl);
cbc3fd
 
cbc3fd
-  elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype));
cbc3fd
-
cbc3fd
-  gfc_get_descriptor_offsets_for_info (type, &data_off, &dtype_off, &dim_off,
cbc3fd
-				       &dim_size, &stride_suboff,
cbc3fd
+  gfc_get_descriptor_offsets_for_info (type, &data_off, &dtype_off, &span_off,
cbc3fd
+				       &dim_off, &dim_size, &stride_suboff,
cbc3fd
 				       &lower_suboff, &upper_suboff);
cbc3fd
 
cbc3fd
+  t = fold_build_pointer_plus (base_decl, span_off);
cbc3fd
+  elem_size = build1 (INDIRECT_REF, gfc_array_index_type, t);
cbc3fd
+
cbc3fd
   t = base_decl;
cbc3fd
   if (!integer_zerop (data_off))
cbc3fd
     t = fold_build_pointer_plus (t, data_off);
cbc3fd
--- gcc/fortran/trans.h
cbc3fd
+++ gcc/fortran/trans.h
cbc3fd
@@ -953,7 +953,6 @@ struct GTY(())	lang_type	 {
cbc3fd
   tree offset;
cbc3fd
   tree dtype;
cbc3fd
   tree dataptr_type;
cbc3fd
-  tree span;
cbc3fd
   tree base_decl[2];
cbc3fd
   tree nonrestricted_type;
cbc3fd
   tree caf_token;
cbc3fd
@@ -969,7 +968,6 @@ struct GTY(()) lang_decl {
cbc3fd
      address of target label.  */
cbc3fd
   tree stringlen;
cbc3fd
   tree addr;
cbc3fd
-  tree span;
cbc3fd
   /* For assumed-shape coarrays.  */
cbc3fd
   tree token, caf_offset;
cbc3fd
   unsigned int scalar_allocatable : 1;
cbc3fd
@@ -979,7 +977,6 @@ struct GTY(()) lang_decl {
cbc3fd
 
cbc3fd
 #define GFC_DECL_ASSIGN_ADDR(node) DECL_LANG_SPECIFIC(node)->addr
cbc3fd
 #define GFC_DECL_STRING_LEN(node) DECL_LANG_SPECIFIC(node)->stringlen
cbc3fd
-#define GFC_DECL_SPAN(node) DECL_LANG_SPECIFIC(node)->span
cbc3fd
 #define GFC_DECL_TOKEN(node) DECL_LANG_SPECIFIC(node)->token
cbc3fd
 #define GFC_DECL_CAF_OFFSET(node) DECL_LANG_SPECIFIC(node)->caf_offset
cbc3fd
 #define GFC_DECL_SAVED_DESCRIPTOR(node) \
cbc3fd
@@ -1028,7 +1025,6 @@ struct GTY(()) lang_decl {
cbc3fd
 #define GFC_TYPE_ARRAY_DTYPE(node) (TYPE_LANG_SPECIFIC(node)->dtype)
cbc3fd
 #define GFC_TYPE_ARRAY_DATAPTR_TYPE(node) \
cbc3fd
   (TYPE_LANG_SPECIFIC(node)->dataptr_type)
cbc3fd
-#define GFC_TYPE_ARRAY_SPAN(node) (TYPE_LANG_SPECIFIC(node)->span)
cbc3fd
 #define GFC_TYPE_ARRAY_BASE_DECL(node, internal) \
cbc3fd
   (TYPE_LANG_SPECIFIC(node)->base_decl[(internal)])
cbc3fd