https://gcc.gnu.org/g:a4ecfe32d3dffa283a1412761de8d847cd17a508
commit a4ecfe32d3dffa283a1412761de8d847cd17a508 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Fri Jul 4 12:54:35 2025 +0200 Revert resolve.cc (rank & shape) Diff: --- gcc/fortran/resolve.cc | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 5b021ad6137b..4a6e951cdf16 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -2800,31 +2800,6 @@ done: } -static void -expression_shape (gfc_expr *e, gfc_array_spec *as) -{ - mpz_t array[GFC_MAX_DIMENSIONS]; - int i; - - if (e->rank <= 0 || e->shape != NULL) - return; - - for (i = 0; i < e->rank; i++) - if (!spec_dimen_size (as, i, &array[i])) - goto fail; - - e->shape = gfc_get_shape (e->rank); - - memcpy (e->shape, array, e->rank * sizeof (mpz_t)); - - return; - -fail: - for (i--; i >= 0; i--) - mpz_clear (array[i]); -} - - /************* Function resolution *************/ /* Resolve a function call known to be generic. @@ -2848,17 +2823,15 @@ resolve_generic_f0 (gfc_expr *expr, gfc_symbol *sym) else if (s->result != NULL && s->result->ts.type != BT_UNKNOWN) expr->ts = s->result->ts; - if (s->result != NULL && s->result->as != NULL) - { - expr->rank = s->result->as->rank; - expr->corank = s->result->as->corank; - expression_shape (expr, s->result->as); - } - else if (s->as != NULL) + if (s->as != NULL) { expr->rank = s->as->rank; expr->corank = s->as->corank; - expression_shape (expr, s->as); + } + else if (s->result != NULL && s->result->as != NULL) + { + expr->rank = s->result->as->rank; + expr->corank = s->result->as->corank; } gfc_set_sym_referenced (expr->value.function.esym); @@ -3002,13 +2975,11 @@ found: { expr->rank = CLASS_DATA (sym)->as->rank; expr->corank = CLASS_DATA (sym)->as->corank; - expression_shape (expr, CLASS_DATA (sym)->as); } else if (sym->as != NULL) { expr->rank = sym->as->rank; expr->corank = sym->as->corank; - expression_shape (expr, sym->as); } return MATCH_YES; @@ -3133,7 +3104,6 @@ resolve_unknown_f (gfc_expr *expr) { expr->rank = sym->as->rank; expr->corank = sym->as->corank; - expression_shape (expr, sym->as); } /* Type of the expression is either the type of the symbol or the @@ -3693,7 +3663,6 @@ resolve_function (gfc_expr *expr) gfc_warning (OPT_Wdeprecated_declarations, "Using function %qs at %L is deprecated", sym->name, &expr->where); - return t; } @@ -5927,6 +5896,9 @@ gfc_resolve_ref (gfc_expr *expr) } +/* Given an expression, determine its shape. This is easier than it sounds. + Leaves the shape array NULL if it is not possible to determine the shape. */ + static void expression_shape (gfc_expr *e) {