[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression simpleif_1
Mikael Morin
mikael@gcc.gnu.org
Fri Jun 13 14:57:30 GMT 2025
https://gcc.gnu.org/g:7f073506885333aa875ef02b34cec82e881ab6bd
commit 7f073506885333aa875ef02b34cec82e881ab6bd
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Tue Apr 22 19:10:58 2025 +0200
Correction régression simpleif_1
Diff:
---
gcc/fortran/trans-array.cc | 3 ++-
gcc/fortran/trans-descriptor.cc | 24 +++---------------------
gcc/fortran/trans-types.cc | 37 +++++++++++++++++++++++++++++++++++++
gcc/fortran/trans-types.h | 2 ++
4 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index c577aa9d5ab7..1f64a58422ba 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3763,7 +3763,8 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss,
tree tmp = build_array_ref_dim (ss, index, info->lbound[array_dim], info->spacing[array_dim]);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
- tmp = fold_convert_loc (input_location, type, tmp);
+ tree fixed_type = gfc_get_unbounded_array_type (type);
+ tmp = fold_convert_loc (input_location, fixed_type, tmp);
info->data = gfc_evaluate_now (tmp, pblock);
}
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 6df34b7bb28a..4c3df7b646c4 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -3887,27 +3887,9 @@ gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
/* Reset array type upper bound if known. */
tree dataptr_type = GFC_TYPE_ARRAY_DATAPTR_TYPE (TREE_TYPE (desc));
- gcc_assert (TREE_CODE (dataptr_type) == POINTER_TYPE);
- tree array_type = TREE_TYPE (dataptr_type);
- gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
- tree index_type = TYPE_DOMAIN (array_type);
- if (index_type != NULL_TREE
- && (TYPE_MAX_VALUE (index_type) != NULL_TREE
- || TYPE_SIZE (array_type) != NULL_TREE
- || TYPE_SIZE_UNIT (array_type) != NULL_TREE))
- {
- tree fixed_index_type = build_distinct_type_copy (index_type);
- TYPE_MAX_VALUE (fixed_index_type) = NULL_TREE;
-
- tree fixed_array_type = build_distinct_type_copy (array_type);
- TYPE_DOMAIN (fixed_array_type) = fixed_index_type;
- TYPE_SIZE (fixed_array_type) = NULL_TREE;
- TYPE_SIZE_UNIT (fixed_array_type) = NULL_TREE;
- layout_type (fixed_array_type);
-
- tree fixed_ptr_type = build_pointer_type (fixed_array_type);
- GFC_TYPE_ARRAY_DATAPTR_TYPE (TREE_TYPE (desc)) = fixed_ptr_type;
- }
+ tree fixed_ptr_type = gfc_get_unbounded_array_type (dataptr_type);
+ if (fixed_ptr_type != dataptr_type)
+ GFC_TYPE_ARRAY_DATAPTR_TYPE (TREE_TYPE (desc)) = fixed_ptr_type;
/* Call the realloc() function. */
tmp = gfc_call_realloc (pblock, arg0, arg1);
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 3e0a54dcabab..e2eb41a4790c 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -4301,4 +4301,41 @@ gfc_build_incomplete_array_type (tree elt_type, tree index_type)
}
+tree
+gfc_get_unbounded_array_type (tree type)
+{
+ bool ptr_wrapper = TREE_CODE (type) == POINTER_TYPE;
+
+ tree array_type;
+ if (ptr_wrapper)
+ array_type = TREE_TYPE (type);
+ else
+ array_type = type;
+
+ gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
+ tree index_type = TYPE_DOMAIN (array_type);
+ if (TYPE_MAX_VALUE (index_type) == NULL_TREE
+ && TYPE_SIZE (array_type) == NULL_TREE
+ && TYPE_SIZE_UNIT (array_type) == NULL_TREE)
+ return type;
+
+ tree modified_index_type = build_distinct_type_copy (index_type);
+ TYPE_MAX_VALUE (modified_index_type) = NULL_TREE;
+
+ tree modified_array_type = build_distinct_type_copy (array_type);
+ TYPE_DOMAIN (modified_array_type) = modified_index_type;
+ TYPE_SIZE (modified_array_type) = NULL_TREE;
+ TYPE_SIZE_UNIT (modified_array_type) = NULL_TREE;
+ layout_type (modified_array_type);
+
+ tree modified_type;
+ if (ptr_wrapper)
+ modified_type = build_pointer_type (modified_array_type);
+ else
+ modified_type = modified_array_type;
+
+ return modified_type;
+}
+
+
#include "gt-fortran-trans-types.h"
diff --git a/gcc/fortran/trans-types.h b/gcc/fortran/trans-types.h
index 5f4da9202d78..6c981ad2f3d7 100644
--- a/gcc/fortran/trans-types.h
+++ b/gcc/fortran/trans-types.h
@@ -125,4 +125,6 @@ tree gfc_get_caf_reference_type ();
tree gfc_build_incomplete_array_type (tree, tree);
+tree gfc_get_unbounded_array_type (tree);
+
#endif
More information about the Gcc-cvs
mailing list