aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2018-01-10 13:18:31 +0200
committerJanne Blomqvist <jb@gcc.gnu.org>2018-01-10 13:18:31 +0200
commit85c2c761f44b23df217e20354bf83bbe5a4632dd (patch)
tree3955534f13e2dafdab1a4c93290d12234dac7751 /gcc/fortran/trans-array.c
parentf6aa5171a1a0091bcc3741b1ffff9e8a962e728c (diff)
downloadgcc-85c2c761f44b23df217e20354bf83bbe5a4632dd.zip
gcc-85c2c761f44b23df217e20354bf83bbe5a4632dd.tar.gz
gcc-85c2c761f44b23df217e20354bf83bbe5a4632dd.tar.bz2
PR 84740 Wrong string length type in bounds check
Need to convert the RHS to the type of the LHS when assigning. Regtested on x86_64-pc-linux-gnu, committed as obvious. gcc/fortran/ChangeLog: 2018-01-10 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/84740 * trans-array.c (gfc_trans_array_ctor_element): Convert RHS to the LHS type when assigning. From-SVN: r256425
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 474a7d1..8a0afe9 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -1562,7 +1562,8 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
if (first_len)
{
gfc_add_modify (&se->pre, first_len_val,
- se->string_length);
+ fold_convert (TREE_TYPE (first_len_val),
+ se->string_length));
first_len = false;
}
else
@@ -1571,7 +1572,9 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
length. */
tree cond = fold_build2_loc (input_location, NE_EXPR,
logical_type_node, first_len_val,
- se->string_length);
+ fold_convert (TREE_TYPE
+ (first_len_val),
+ se->string_length));
gfc_trans_runtime_check
(true, false, cond, &se->pre, &expr->where,
"Different CHARACTER lengths (%ld/%ld) in array constructor",