Hi Mikael, <snip> > > --- 5198,5222 ---- > > /* In all other cases evaluate the expr3 and create a > > temporary. */ > > gfc_init_se (&se, NULL); > > + /* For more complicated expression, the decision when to get the > > + descriptor and when to get a reference is depending on more > > + conditions. The descriptor is only retrieved for functions > > + that are intrinsic, elemental user-defined and known, or > > neither > > + of the two, or are a class or type, that has a not deferred > > type > > + array_spec. */ > > if (code->expr3->rank != 0 > > ! && (code->expr3->expr_type != EXPR_FUNCTION > > ! || code->expr3->value.function.isym > > ! || (code->expr3->value.function.esym && > > ! code->expr3->value.function.esym->attr.elemental) > > ! || (!code->expr3->value.function.isym > > ! && !code->expr3->value.function.esym) > > ! || (code->expr3->ts.type == BT_DERIVED > > ! && code->expr3->ts.u.derived->as > > ! && code->expr3->ts.u.derived->as->type != > > AS_DEFERRED) ! || (code->expr3->ts.type == BT_CLASS > > ! && CLASS_DATA (code->expr3)->as > > ! && CLASS_DATA (code->expr3)->as->type != > > AS_DEFERRED))) gfc_conv_expr_descriptor (&se, code->expr3); > > else > > gfc_conv_expr_reference (&se, code->expr3); > What is the rationale for choosing between gfc_conv_expr_descriptor and > gfc_conv_expr_reference?
The rationale is to get the array descriptor for all arrays, but deferred type ones. For deferred type ones gfc_conv_expr_descriptor either failed or the result does not satisfy further processing needs. > Is it contiguous array vs non-contiguous or needing an evaluation? Neither. How the array is shaped is not of my concern. > For example why not use gfc_conv_expr_descriptor for derived type arrays? But it does use gfc_conv_expr_descriptor for derived type arrays! It is just not used for deferred ones. > > *************** > > *** 5646,5659 **** > > } > > else if (code->expr3->ts.type == BT_CHARACTER) > > { > > ! tmp = INDIRECT_REF_P (se.expr) ? > > se.expr : > > build_fold_indirect_ref_loc (input_location, > > se.expr); > > ! gfc_trans_string_copy (&block, al_len, tmp, > > ! code->expr3->ts.kind, > > ! expr3_len, expr3, > > ! code->expr3->ts.kind); > > tmp = NULL_TREE; > > } > > else if (al->expr->ts.type == BT_CLASS) > > --- 5658,5707 ---- > > } > > else if (code->expr3->ts.type == BT_CHARACTER) > > { > > ! tree dst, src, dlen, slen; > > ! /* For arrays of char arrays, a ref to the data component > > still ! needs to be added, because se.expr upto now only > > contains the ! descritor. */ > > ! if (expr->ref && se.expr && TREE_TYPE (se.expr) != NULL_TREE > > ! && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se.expr))) > > ! { > > ! dst = gfc_conv_array_data (se.expr); > > ! src = gfc_conv_array_data (expr3); > > ! /* For CHARACTER (len=string_length), dimension (nelems) > > ! compute the total length of the string to copy. */ > > ! if (nelems) > > ! { > > ! dlen = fold_build2_loc (input_location, MULT_EXPR, > > ! size_type_node, > > ! fold_convert > > (size_type_node, ! > > se.string_length), ! > > fold_convert > > (size_type_node, ! > > nelems)); ! > > slen = fold_build2_loc (input_location, MULT_EXPR, ! > > size_type_node, ! > > fold_convert > > (size_type_node, ! > > expr3_len), ! > > fold_convert > > (size_type_node, ! > > nelems)); ! > > } ! else ! { ! > > dlen = se.string_length; ! slen > > = expr3_len; ! } ! } > > ! else > > ! { > > ! dst = INDIRECT_REF_P (se.expr) ? > > se.expr : > > build_fold_indirect_ref_loc (input_location, > > se.expr); > > ! src = expr3; > > ! dlen = al_len; > > ! slen = expr3_len; > > ! } > > ! gfc_trans_string_copy (&block, dlen, dst, > > code->expr3->ts.kind, ! slen, src, > > code->expr3->ts.kind); tmp = NULL_TREE; > > } > > else if (al->expr->ts.type == BT_CLASS) > This seems to assume that the array is contiguous. > Can't we just fall back to the default case for characters? What do you take as the default case for characters? You are right the above code assumes the array of char arrays is contiguous, which I admit to fail when the array isn't. Any experience of how to do this better? gfc_trans_string_copy is not capable of copying multiple strings, so how to do it most future safe? Any idea? Regards, Andre -- Andre Vehreschild * Email: vehre ad gmx dot de