fortran: Remove always false dummy pointer conditional After the previous change, the `formal_ptr' argument of gfc_conv_subref_array_arg is false everywhere the function is used. Remove it. The argument was controling the generation of one-based array descriptor bounds when the dummy argument had the pointer attribute, which is excluded in the contexts where the function is used, that is when a copy-in and/or copy-out of the argument is to be generated. Remove that as well. gcc/fortran/ChangeLog: * trans.h (gfc_conv_subref_array_arg): Remove argument formal_ptr. * trans-expr.cc (gfc_conv_subref_array_arg): Likewise. Remove code depending on the argument being true. (gfc_conv_gfc_desc_to_cfi_desc, gfc_conv_procedure_call): Update callers. * trans-array.cc (gfc_conv_array_parameter): Likewise. * trans-io.cc (set_internal_unit, gfc_trans_transfer): Likewise. * trans-stmt.cc (trans_associate_var, forall_make_variable_temp): Likewise.
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index ea72cbd..83735ea 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc
@@ -9462,7 +9462,7 @@ { gfc_conv_subref_array_arg (se, expr, g77, fsym ? fsym->attr.intent : INTENT_INOUT, - false, fsym, proc_name, sym, true); + fsym, proc_name, sym, true); return; }
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 8976c15..2865db1 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc
@@ -5461,10 +5461,10 @@ after the function call. */ void gfc_conv_subref_array_arg (gfc_se *se, gfc_expr * expr, int g77, - sym_intent intent, bool formal_ptr, - const gfc_symbol *fsym, const char *proc_name, - gfc_symbol *sym, bool check_contiguous, - bool deep_copy, bool span_only) + sym_intent intent, const gfc_symbol *fsym, + const char *proc_name, gfc_symbol *sym, + bool check_contiguous, bool deep_copy, + bool span_only) { gfc_se lse; gfc_se rse; @@ -5477,7 +5477,6 @@ tree tmp_index; tree tmp; tree base_type; - tree size; stmtblock_t body; int n; int dimen; @@ -5730,46 +5729,6 @@ if (expr->ts.type == BT_CHARACTER) parmse->string_length = expr->ts.u.cl->backend_decl; - /* Determine the offset for pointer formal arguments and set the - lbounds to one. */ - if (formal_ptr) - { - size = gfc_index_one_node; - offset = gfc_index_zero_node; - for (n = 0; n < dimen; n++) - { - tmp = gfc_conv_descriptor_ubound_get (parmse->expr, - gfc_rank_cst[n]); - tmp = fold_build2_loc (input_location, PLUS_EXPR, - gfc_array_index_type, tmp, - gfc_index_one_node); - gfc_conv_descriptor_ubound_set (&parmse->pre, - parmse->expr, - gfc_rank_cst[n], - tmp); - gfc_conv_descriptor_lbound_set (&parmse->pre, - parmse->expr, - gfc_rank_cst[n], - gfc_index_one_node); - size = gfc_evaluate_now (size, &parmse->pre); - offset = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, - offset, size); - offset = gfc_evaluate_now (offset, &parmse->pre); - tmp = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, - rse.loop->to[n], rse.loop->from[n]); - tmp = fold_build2_loc (input_location, PLUS_EXPR, - gfc_array_index_type, - tmp, gfc_index_one_node); - size = fold_build2_loc (input_location, MULT_EXPR, - gfc_array_index_type, size, tmp); - } - - gfc_conv_descriptor_offset_set (&parmse->pre, parmse->expr, - offset); - } - /* We want either the address for the data or the address of the descriptor, depending on the mode of passing array arguments. */ if (g77) @@ -6159,7 +6118,7 @@ bool optional = fsym->attr.optional; fsym->attr.optional = 0; gfc_conv_subref_array_arg (&se, e, false, fsym->attr.intent, - false, fsym, fsym->ns->proc_name->name, + fsym, fsym->ns->proc_name->name, NULL, /* check_contiguous= */ true); fsym->attr.optional = optional; } @@ -8268,7 +8227,7 @@ the copy is suppressed and a null pointer passed when an optional actual argument is absent. */ gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, INTENT_IN, - false, fsym, sym->name, + fsym, sym->name, e->expr_type == EXPR_VARIABLE ? e->symtree->n.sym : NULL, false, true); @@ -8282,7 +8241,7 @@ gfc_expr *var = pointer_result_var (&parmse.pre, e); gfc_conv_subref_array_arg (&parmse, var, nodesc_arg, fsym ? fsym->attr.intent : INTENT_INOUT, - false, fsym, sym->name, NULL, true, false, + fsym, sym->name, NULL, true, false, dummy_accepts_strided_arg (fsym, nodesc_arg)); gfc_symtree *st = var->symtree; gfc_free_expr (var); @@ -8306,7 +8265,7 @@ bool whole_span = is_whole_span_addressed_dummy (e); gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, fsym ? fsym->attr.intent : INTENT_INOUT, - false, fsym, sym->name, NULL, whole_span, false, + fsym, sym->name, NULL, whole_span, false, whole_span && dummy_accepts_strided_arg (fsym, nodesc_arg)); @@ -8329,7 +8288,7 @@ is converted to a temporary, which is passed and then written back after the procedure call. */ gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, - fsym->attr.intent, false); + fsym->attr.intent); else if (gfc_is_class_array_function (e) && fsym && fsym->ts.type == BT_DERIVED @@ -8339,8 +8298,7 @@ intent in. */ { e->must_finalize = 1; - gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, - INTENT_IN, false); + gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, INTENT_IN); } else if (fsym && fsym->attr.contiguous && (fsym->attr.target @@ -8350,7 +8308,7 @@ && e->rank != -1) { gfc_conv_subref_array_arg (&parmse, e, nodesc_arg, - fsym->attr.intent, false); + fsym->attr.intent); } else {
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc index 732c592..a91763b 100644 --- a/gcc/fortran/trans-io.cc +++ b/gcc/fortran/trans-io.cc
@@ -944,7 +944,7 @@ /* Use a temporary for components of arrays of derived types or substring array references. */ gfc_conv_subref_array_arg (&se, e, 0, - last_dt == READ ? INTENT_IN : INTENT_OUT, false); + last_dt == READ ? INTENT_IN : INTENT_OUT); tmp = build_fold_indirect_ref_loc (input_location, se.expr); se.expr = gfc_build_addr_expr (pchar_type_node, tmp); @@ -2706,7 +2706,7 @@ if (seen_vector && last_dt == READ) { /* Create a temp, read to that and copy it back. */ - gfc_conv_subref_array_arg (&se, expr, 0, INTENT_OUT, false); + gfc_conv_subref_array_arg (&se, expr, 0, INTENT_OUT); tmp = se.expr; } else
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 4a09da0..74fd531 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc
@@ -2064,7 +2064,7 @@ gfc_se init; gcc_assert (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (sym->backend_decl))); gfc_init_se (&init, NULL); - gfc_conv_subref_array_arg (&init, e, false, INTENT_INOUT, false); + gfc_conv_subref_array_arg (&init, e, false, INTENT_INOUT); init.expr = build_fold_indirect_ref_loc (input_location, init.expr); gfc_add_modify (&init.pre, sym->backend_decl, init.expr); gfc_add_init_cleanup (block, gfc_finish_block (&init.pre), @@ -4162,7 +4162,7 @@ if (old_sym->attr.dimension) { gfc_init_se (&tse, NULL); - gfc_conv_subref_array_arg (&tse, e, 0, INTENT_IN, false); + gfc_conv_subref_array_arg (&tse, e, 0, INTENT_IN); gfc_add_block_to_block (pre, &tse.pre); gfc_add_block_to_block (post, &tse.post); tse.expr = build_fold_indirect_ref_loc (input_location, tse.expr);
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index d03f029..3487caf 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h
@@ -560,7 +560,7 @@ int gfc_conv_procedure_call (gfc_se *, gfc_symbol *, gfc_actual_arglist *, gfc_expr *, vec<tree, va_gc> *); -void gfc_conv_subref_array_arg (gfc_se *, gfc_expr *, int, sym_intent, bool, +void gfc_conv_subref_array_arg (gfc_se *, gfc_expr *, int, sym_intent, const gfc_symbol *fsym = NULL, const char *proc_name = NULL, gfc_symbol *sym = NULL,