diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-09-13 18:42:16 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2018-09-13 12:42:16 -0600 |
commit | 8b393e9fb21ee2889eb341ec20e6e84e6f4de2a5 (patch) | |
tree | 98c317e5331d7d48ed848a47559d9112e5fa0912 /gcc/fortran/trans-array.c | |
parent | 9fd1ec33710add80fb8efbe7ef31a0ab92d0540f (diff) | |
download | gcc-8b393e9fb21ee2889eb341ec20e6e84e6f4de2a5.zip gcc-8b393e9fb21ee2889eb341ec20e6e84e6f4de2a5.tar.gz gcc-8b393e9fb21ee2889eb341ec20e6e84e6f4de2a5.tar.bz2 |
trans-array.c (gfc_conv_array_initializer): Remove excess precision from overlength string initializers.
* trans-array.c (gfc_conv_array_initializer): Remove excess precision
from overlength string initializers.
From-SVN: r264285
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index adb2c05..473bfc5 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -5956,6 +5956,26 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) { case EXPR_CONSTANT: gfc_conv_constant (&se, c->expr); + + /* See gfortran.dg/charlen_15.f90 for instance. */ + if (TREE_CODE (se.expr) == STRING_CST + && TREE_CODE (type) == ARRAY_TYPE) + { + tree atype = type; + while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE) + atype = TREE_TYPE (atype); + if (TREE_CODE (TREE_TYPE (atype)) == INTEGER_TYPE + && tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) + > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) + { + unsigned HOST_WIDE_INT size + = tree_to_uhwi (TYPE_SIZE_UNIT (atype)); + const char *p = TREE_STRING_POINTER (se.expr); + + se.expr = build_string (size, p); + TREE_TYPE (se.expr) = atype; + } + } break; case EXPR_STRUCTURE: |