[gcc(refs/users/mikael/heads/refactor_descriptor_v03)] Mise à jour commentaires.
Mikael Morin
mikael@gcc.gnu.org
Fri Mar 14 16:14:24 GMT 2025
https://gcc.gnu.org/g:8d1b1cde804abb626be2b782212fb84c3988d7de
commit 8d1b1cde804abb626be2b782212fb84c3988d7de
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Fri Feb 14 12:23:42 2025 +0100
Mise à jour commentaires.
Diff:
---
gcc/fortran/trans-array.cc | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 5b3f0ad58f0f..3ac5a36a73e6 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -8322,6 +8322,13 @@ descriptor_element_size (tree descriptor, tree expr3_elem_size,
}
+/* Calculates the memory size of an array, given the size of its elements,
+ the number of them, and the predicate whether the array is empty.
+ elements_count = (size_t) elements_count;
+ overflow += element_size == 0 ? 0: (MAX/element_size < elements_count ? 1: 0);
+ tmp = elements_count * element_size;
+ return (tmp); */
+
static tree
get_array_memory_size (tree element_size, tree elements_count,
tree empty_array_cond, stmtblock_t * pblock,
@@ -8336,8 +8343,6 @@ get_array_memory_size (tree element_size, tree elements_count,
stmtblock_t thenblock;
stmtblock_t elseblock;
-
-
elements_count = fold_convert (size_type_node, elements_count);
/* First check for overflow. Since an array of type character can
@@ -8386,11 +8391,10 @@ get_array_memory_size (tree element_size, tree elements_count,
}
-/* Fills in an array descriptor, and returns the size of the array.
- The size will be a simple_val, ie a variable or a constant. Also
- calculates the offset of the base. The pointer argument overflow,
- which should be of integer type, will increase in value if overflow
- occurs during the size calculation. Returns the size of the array.
+/* Fills in an array descriptor, and returns the number of elements in the
+ array. The pointer argument overflow, which should be of integer type,
+ will increase in value if overflow occurs during the size calculation.
+ Also sets the condition whether the array is empty through empty_array_cond.
{
stride = 1;
offset = 0;
@@ -8407,13 +8411,9 @@ get_array_memory_size (tree element_size, tree elements_count,
}
for (n = rank; n < rank+corank; n++)
(Set lcobound/ucobound as above.)
- element_size = sizeof (array element);
- if (!rank)
- return element_size
- stride = (size_t) stride;
- overflow += element_size == 0 ? 0: (MAX/element_size < stride ? 1: 0);
- stride = stride * element_size;
- return (stride);
+ if (rank == 0)
+ return 1;
+ return stride;
} */
/*GCC ARRAYS*/
@@ -8653,9 +8653,6 @@ gfc_array_init_count (tree descriptor, int rank, int corank, gfc_expr ** lower,
*empty_array_cond = empty_cond;
- /* The stride is the number of elements in the array, so multiply by the
- size of an element to get the total size. */
-
if (rank == 0)
return gfc_index_one_node;
@@ -8842,8 +8839,10 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
e3_has_nodescriptor, expr, element_size,
explicit_ts, &empty_array_cond);
- tree size = get_array_memory_size (element_size, count, empty_array_cond,
- &se->pre, &overflow);
+ tree size = rank == 0
+ ? element_size
+ : get_array_memory_size (element_size, count, empty_array_cond,
+ &se->pre, &overflow);
if (dimension)
{
More information about the Gcc-cvs
mailing list