diff options
author | Thomas Schwinge <tschwinge@baylibre.com> | 2024-03-11 00:59:26 +0100 |
---|---|---|
committer | Thomas Schwinge <tschwinge@baylibre.com> | 2024-03-11 00:59:26 +0100 |
commit | ec26db53513f9de267b85c1c8f8db838dcd09d36 (patch) | |
tree | f3df366d23091e1a526a2569f7d6e6c1f8ae4fe1 /gcc/fortran/trans-array.cc | |
parent | 333fe5b0f141b3cf2fa1890e72fbc0d2551742cc (diff) | |
parent | 9b5b2c9f95056f97cf95f0e8d970015aa586497b (diff) | |
download | gcc-ec26db53513f9de267b85c1c8f8db838dcd09d36.zip gcc-ec26db53513f9de267b85c1c8f8db838dcd09d36.tar.gz gcc-ec26db53513f9de267b85c1c8f8db838dcd09d36.tar.bz2 |
Merge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD
Diffstat (limited to 'gcc/fortran/trans-array.cc')
-rw-r--r-- | gcc/fortran/trans-array.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 1640587..e0fc8eb 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -2852,6 +2852,23 @@ trans_array_constructor (gfc_ss * ss, locus * where) const_string = get_array_ctor_strlen (&outer_loop->pre, c, &ss_info->string_length); force_new_cl = true; + + /* Initialize "len" with string length for bounds checking. */ + if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) + && !typespec_chararray_ctor + && ss_info->string_length) + { + gfc_se length_se; + + gfc_init_se (&length_se, NULL); + gfc_add_modify (&length_se.pre, first_len_val, + fold_convert (TREE_TYPE (first_len_val), + ss_info->string_length)); + ss_info->string_length = gfc_evaluate_now (ss_info->string_length, + &length_se.pre); + gfc_add_block_to_block (&outer_loop->pre, &length_se.pre); + gfc_add_block_to_block (&outer_loop->post, &length_se.post); + } } /* Complex character array constructors should have been taken care of |