View | Details | Return to bug 64290 | Differences between
and this patch

Collapse All | Expand All

(-)a/gcc/fortran/trans-expr.c (+27 lines)
Lines 11389-11394 gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, Link Here
11389
11389
11390
  /* Add the pre blocks to the body.  */
11390
  /* Add the pre blocks to the body.  */
11391
  gfc_add_block_to_block (&body, &rse.pre);
11391
  gfc_add_block_to_block (&body, &rse.pre);
11392
11393
  /* F2018 (7.5.6.3): "When an intrinsic assignment statement is executed
11394
     (10.2.1.3), if the variable is not an unallocated allocatable variable,
11395
     it is finalized after evaluation of expr and before the definition of
11396
     the variable. If the variable is an allocated allocatable variable, or
11397
     has an allocated allocatable subobject, that would be deallocated by
11398
     intrinsic assignment, the finalization occurs before the deallocation */
11399
  stmtblock_t final_block;
11400
  gfc_init_block (&final_block);
11401
  if (!expr1->symtree->n.sym->attr.artificial
11402
      && !expr1->symtree->n.sym->ns->proc_name->attr.artificial
11403
      && gfc_add_finalizer_call (&final_block, expr1))
11404
    {
11405
      tree tmp2 = gfc_finish_block (&final_block);
11406
      if (expr1->symtree->n.sym->attr.optional)
11407
	{
11408
	  tree cond = gfc_conv_expr_present (expr1->symtree->n.sym);
11409
	  tmp2 = build3_loc (input_location, COND_EXPR, void_type_node,
11410
			     cond, tmp2, build_empty_stmt (input_location));
11411
	}
11412
11413
      if (lss == gfc_ss_terminator)
11414
	gfc_add_expr_to_block (&body, tmp2);
11415
      else
11416
	gfc_prepend_expr_to_block (&loop.pre, tmp2);
11417
    }
11418
11392
  gfc_add_block_to_block (&body, &lse.pre);
11419
  gfc_add_block_to_block (&body, &lse.pre);
11393
  gfc_add_expr_to_block (&body, tmp);
11420
  gfc_add_expr_to_block (&body, tmp);
11394
  /* Add the post blocks to the body.  */
11421
  /* Add the post blocks to the body.  */

Return to bug 64290