aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2024-07-18 21:15:48 +0200
committerHarald Anlauf <anlauf@gmx.de>2024-07-19 17:40:27 +0200
commitc93be1606ecf8e0f65b96b67aa023fb456ceb3a3 (patch)
tree23c89bde7507677e7668fa36fd0bd57b7bfe6d7d /gcc/fortran
parentb2f47a5c1d5204131660ea0372a08e692df8844e (diff)
downloadgcc-c93be1606ecf8e0f65b96b67aa023fb456ceb3a3.zip
gcc-c93be1606ecf8e0f65b96b67aa023fb456ceb3a3.tar.gz
gcc-c93be1606ecf8e0f65b96b67aa023fb456ceb3a3.tar.bz2
Fortran: character array constructor with >= 4 constant elements [PR103115]
gcc/fortran/ChangeLog: PR fortran/103115 * trans-array.cc (gfc_trans_array_constructor_value): If the first element of an array constructor is deferred-length character and therefore does not have an element size known at compile time, do not try to collect subsequent constant elements into a constructor for optimization. gcc/testsuite/ChangeLog: PR fortran/103115 * gfortran.dg/string_array_constructor_4.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/trans-array.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index dc3de6c..c93a5f1 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2147,7 +2147,9 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock,
p = gfc_constructor_next (p);
n++;
}
- if (n < 4)
+ /* Constructor with few constant elements, or element size not
+ known at compile time (e.g. deferred-length character). */
+ if (n < 4 || !INTEGER_CST_P (TYPE_SIZE_UNIT (type)))
{
/* Scalar values. */
gfc_init_se (&se, NULL);