@@ -5513,20 +5513,14 @@ convert_to_block_forall(int old_forall_ast)
55135513static void
55145514gen_init_unl_poly_desc (int dest_sdsc_ast , int src_sdsc_ast )
55155515{
5516- int fsptr , argt , val , ast ;
5517- if (XBIT (68 , 0x1 )) {
5518- fsptr = sym_mkfunc_nodesc (mkRteRtnNm (RTE_init_unl_poly_desc ), DT_NONE );
5519-
5520- } else
5521- fsptr = sym_mkfunc_nodesc (mkRteRtnNm (RTE_init_unl_poly_desc ), DT_NONE );
5522-
5523- argt = mk_argt (3 );
5516+ int fsptr = sym_mkfunc_nodesc (mkRteRtnNm (RTE_init_unl_poly_desc ), DT_NONE );
5517+ int argt = mk_argt (3 );
5518+ int val = mk_cval1 (43 , DT_INT );
5519+ int ast = mk_id (fsptr );
55245520 ARGT_ARG (argt , 0 ) = dest_sdsc_ast ;
55255521 ARGT_ARG (argt , 1 ) = src_sdsc_ast ;
5526- val = mk_cval1 (43 , DT_INT );
55275522 val = mk_unop (OP_VAL , val , DT_INT );
55285523 ARGT_ARG (argt , 2 ) = val ;
5529- ast = mk_id (fsptr );
55305524 ast = mk_func_node (A_CALL , ast , 3 , argt );
55315525 add_stmt (ast );
55325526}
@@ -5665,15 +5659,6 @@ is_associatable_variable_sst(SST *rhs)
56655659 return FALSE;
56665660}
56675661
5668- /* Build an AST that references the byte length field in a descriptor.
5669- */
5670- static int
5671- get_descriptor_length_ast (int descriptor_ast )
5672- {
5673- int subs = mk_isz_cval (get_byte_len_indx (), astb .bnd .dtype );
5674- return mk_subscr (descriptor_ast , & subs , 1 , astb .bnd .dtype );
5675- }
5676-
56775662/* Implement an association for one of these constructs:
56785663 *
56795664 * ASSOCIATE(a => variable)
@@ -5712,6 +5697,7 @@ construct_association(int lhs_sptr, SST *rhs, int stmt_dtype, LOGICAL is_class)
57125697 LOGICAL is_lhs_unl_poly ;
57135698 int rhs_descriptor_ast = 0 ;
57145699 LOGICAL does_lhs_need_runtime_type ;
5700+ int lhs_length_ast ;
57155701
57165702 if (!(rhs_ast = SST_ASTG (rhs ))) {
57175703 mkexpr (rhs );
@@ -5727,16 +5713,19 @@ construct_association(int lhs_sptr, SST *rhs, int stmt_dtype, LOGICAL is_class)
57275713 }
57285714
57295715 lhs_dtype = stmt_dtype > 0 ? stmt_dtype : rhs_dtype ;
5730- lhs_element_dtype = lhs_dtype ;
57315716 if (is_array_dtype (lhs_dtype )) {
57325717 int rank = get_ast_rank (rhs_ast );
57335718 is_array = rank > 0 ;
57345719 if (is_array ) {
5735- lhs_element_dtype = DTY (lhs_dtype + 1 );
5720+ lhs_element_dtype = array_element_dtype (lhs_dtype );
5721+ lhs_element_dtype = change_assumed_char_to_deferred (lhs_element_dtype );
57365722 lhs_dtype = get_array_dtype (rank , lhs_element_dtype );
57375723 ADD_DEFER (lhs_dtype ) = TRUE;
57385724 ADD_NOBOUNDS (lhs_dtype ) = TRUE;
57395725 }
5726+ } else {
5727+ lhs_dtype = change_assumed_char_to_deferred (lhs_dtype );
5728+ lhs_element_dtype = lhs_dtype ;
57405729 }
57415730 is_lhs_runtime_length_char = is_dtype_runtime_length_char (lhs_dtype );
57425731
@@ -5875,7 +5864,8 @@ construct_association(int lhs_sptr, SST *rhs, int stmt_dtype, LOGICAL is_class)
58755864 }
58765865
58775866 /* For TYPE IS statements with intrinsic types, set the LHS type
5878- * directly. */
5867+ * directly.
5868+ */
58795869 if (SDSCG (lhs_sptr ) > NOSYM && stmt_dtype && !is_class &&
58805870 DTY (lhs_element_dtype ) != TY_DERIVED ) {
58815871 int args = mk_argt (2 );
@@ -5888,30 +5878,17 @@ construct_association(int lhs_sptr, SST *rhs, int stmt_dtype, LOGICAL is_class)
58885878 /* Generate code to initialize, when necessary, the byte length field
58895879 * in the left-hand side's descriptor, if it exists.
58905880 */
5891- if (SDSCG (lhs_sptr ) > NOSYM ) {
5892- int dest_len_ast = 0 ;
5893- if (is_lhs_runtime_length_char ) {
5894- dest_len_ast = get_byte_len (SDSCG (lhs_sptr ));
5895- } else if (is_lhs_unl_poly || is_array ) {
5896- dest_len_ast = get_descriptor_length_ast (mk_id (SDSCG (lhs_sptr )));
5897- }
5898- if (dest_len_ast ) {
5899- int len_ast = 0 ;
5900- if (is_dtype_runtime_length_char (rhs_dtype )) {
5901- len_ast = string_expr_length (rhs_ast );
5902- } else if (stmt_dtype && !is_class /* TYPE IS(stmt_dtype) */ &&
5903- !is_lhs_runtime_length_char ) {
5904- len_ast = size_ast (lhs_sptr , lhs_element_dtype );
5905- } else if (rhs_descriptor_ast &&
5906- is_array_dtype (A_DTYPEG (rhs_descriptor_ast ))) {
5907- len_ast = get_descriptor_length_ast (rhs_descriptor_ast );
5908- }
5909- if (len_ast ) {
5910- int assignment_ast =
5911- mk_assn_stmt (dest_len_ast , len_ast , astb .bnd .dtype );
5912- add_stmt (assignment_ast );
5913- }
5914- }
5881+ lhs_length_ast = symbol_descriptor_length_ast (lhs_sptr , 0 /*no AST*/ );
5882+ if (lhs_length_ast > 0 ) {
5883+ SPTR size_sptr = stmt_dtype > DT_NONE &&
5884+ !is_class /* TYPE IS */ &&
5885+ !is_lhs_runtime_length_char ? lhs_sptr
5886+ : NOSYM ;
5887+ int rhs_length_ast = get_value_length_ast (rhs_dtype , rhs_ast , size_sptr ,
5888+ lhs_element_dtype ,
5889+ rhs_descriptor_ast );
5890+ if (rhs_length_ast > 0 )
5891+ add_stmt (mk_assn_stmt (lhs_length_ast , rhs_length_ast , astb .bnd .dtype ));
59155892 }
59165893
59175894 return lhs_sptr ;
0 commit comments