https://gcc.gnu.org/g:115f180f14c62dd4a22b4a5d2086a593a9826ed0
commit 115f180f14c62dd4a22b4a5d2086a593a9826ed0 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Fri Apr 11 14:07:45 2025 +0200 Correction ICE PR94022 Diff: --- gcc/fortran/trans-array.cc | 2 +- gcc/fortran/trans-descriptor.cc | 17 +++++++++++++---- gcc/fortran/trans-types.cc | 16 ++++++++++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 3e36a1dd15b9..9f17a6d8eac7 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6889,7 +6889,7 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, { array = build_array_ref (desc, array, gfc_index_zero_node, non_negative_strides, gfc_index_zero_node, - NULL_TREE, nullptr); + gfc_conv_array_spacing (desc, i), nullptr); } tmp = array; diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 4bbc05be7a4e..88062e3b8b3a 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -980,10 +980,19 @@ gfc_build_desc_array_type (tree desc_type, tree etype, int dimen, tree * lbound, upper = gfc_descriptor::get_ubound (root, dim); } - tree idx_type = build_range_type (gfc_array_index_type, lower, upper); - - type = build_array_type (type, idx_type); - layout_type (type); + tree index_type = build_range_type (gfc_array_index_type, lower, upper); + + tree elt_type = type; + type = make_node (ARRAY_TYPE); + TREE_TYPE (type) = elt_type; + TYPE_DOMAIN (type) = index_type; + TYPE_ADDR_SPACE (type) = TYPE_ADDR_SPACE (elt_type); + + /* Set TYPE_STRUCTURAL_EQUALITY_P. */ + if (TYPE_STRUCTURAL_EQUALITY_P (elt_type) + || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type)) + || in_lto_p) + SET_TYPE_STRUCTURAL_EQUALITY (type); } return type; diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 4661ff92fa8d..5e647d2965e5 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -1855,7 +1855,11 @@ build_nested_array_types (tree etype, tree lbound[GFC_MAX_DIMENSIONS], for (int i = 0; i < rank; i++) { - tree idx_type = build_range_type (gfc_array_index_type, lbound[i], ubound[i]); + tree idx_type; + if (lbound[i]) + idx_type = build_range_type (gfc_array_index_type, lbound[i], ubound[i]); + else + idx_type = gfc_array_index_type; type = build_array_type (type, idx_type); layout_type (type); } @@ -2197,14 +2201,14 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound, tree spacing; if (packed == 0) { - stride = gfc_index_one_node; - spacing = fold_convert_loc (input_location, gfc_array_index_type, - TYPE_SIZE_UNIT (etype)); + stride = NULL_TREE; + spacing = NULL_TREE; } else { - stride = NULL_TREE; - spacing = NULL_TREE; + stride = gfc_index_one_node; + spacing = fold_convert_loc (input_location, gfc_array_index_type, + TYPE_SIZE_UNIT (etype)); } for (n = 0; n < dimen + codimen; n++) {