aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-03-11 15:37:37 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-03-17 20:50:31 +0100
commit3cca6b5fa51fd271644082761de85e89fd56d69c (patch)
tree31defd7d93a73d00bdf0f03c4788a410d3aeb012 /gcc/fortran
parentc5cb9d8819eb9551d23f77e63cb3399115f0aab8 (diff)
downloadgcc-3cca6b5fa51fd271644082761de85e89fd56d69c.zip
gcc-3cca6b5fa51fd271644082761de85e89fd56d69c.tar.gz
gcc-3cca6b5fa51fd271644082761de85e89fd56d69c.tar.bz2
Fortran: fix bounds check for copying of class expressions [PR106945]
In the bounds check for copying of class expressions, the number of elements determined from a descriptor, returned as type gfc_array_index_type (i.e. a signed type), should be converted to the type of the passed element count, which is of type size_type_node (i.e. unsigned), for use in comparisons. gcc/fortran/ChangeLog: PR fortran/106945 * trans-expr.c (gfc_copy_class_to_class): Convert element counts in bounds check to common type for comparison. gcc/testsuite/ChangeLog: PR fortran/106945 * gfortran.dg/pr106945.f90: New test. (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/trans-expr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 602df7d..7dfd19f 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1437,6 +1437,7 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems, bool unlimited)
name = (const char *)(DECL_NAME (to)->identifier.id.str);
from_len = gfc_conv_descriptor_size (from_data, 1);
+ from_len = fold_convert (TREE_TYPE (orig_nelems), from_len);
tmp = fold_build2_loc (input_location, NE_EXPR,
logical_type_node, from_len, orig_nelems);
msg = xasprintf ("Array bound mismatch for dimension %d "