https://gcc.gnu.org/g:91f51281d03fa0951fad216ee9a1f894656fb8c0
commit 91f51281d03fa0951fad216ee9a1f894656fb8c0 Author: Mikael Morin <[email protected]> Date: Wed Sep 9 13:53:58 2026 +0200 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. gcc/fortran/ChangeLog: * trans.h (gfc_conv_subref_array_arg): Remove argument formal_ptr. * trans-expr.cc (gfc_conv_subref_array_arg): Likewise. (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: --- gcc/fortran/trans-array.cc | 2 +- gcc/fortran/trans-expr.cc | 62 ++++++++-------------------------------------- gcc/fortran/trans-io.cc | 4 +-- gcc/fortran/trans-stmt.cc | 4 +-- gcc/fortran/trans.h | 2 +- 5 files changed, 16 insertions(+), 58 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 3e3e88012efd..b8bf90680dec 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9371,7 +9371,7 @@ gfc_conv_array_parameter (gfc_se *se, gfc_expr *expr, bool g77, { 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 9ebab8652106..b186033c3fea 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -5555,10 +5555,10 @@ gfc_apply_interface_mapping (gfc_interface_mapping * mapping, 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; @@ -5571,7 +5571,6 @@ gfc_conv_subref_array_arg (gfc_se *se, gfc_expr * expr, int g77, tree tmp_index; tree tmp; tree base_type; - tree size; stmtblock_t body; int n; int dimen; @@ -5824,46 +5823,6 @@ class_array_fcn: 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) @@ -6248,7 +6207,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) 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; } @@ -8301,7 +8260,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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); @@ -8322,7 +8281,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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)); @@ -8345,7 +8304,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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 @@ -8355,8 +8314,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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 @@ -8366,7 +8324,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && 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 94a782f3af76..73f5a5ac0dc6 100644 --- a/gcc/fortran/trans-io.cc +++ b/gcc/fortran/trans-io.cc @@ -944,7 +944,7 @@ set_internal_unit (stmtblock_t * block, stmtblock_t * post_block, /* 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); @@ -2697,7 +2697,7 @@ gfc_trans_transfer (gfc_code * code) 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 6f515753740e..acdc56a485e1 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -2063,7 +2063,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) 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), @@ -4157,7 +4157,7 @@ forall_make_variable_temp (gfc_code *c, stmtblock_t *pre, stmtblock_t *post) 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 bcb466ffe8ff..19b49dbf8174 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -560,7 +560,7 @@ int gfc_is_intrinsic_libcall (gfc_expr *); 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,
