Commit 85c2c761 by Janne Blomqvist

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
parent f6aa5171
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.
2018-01-09 Steven G. Kargl <kargl@gcc.gnu.org> 2018-01-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/83742 PR fortran/83742
......
...@@ -1562,7 +1562,8 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc, ...@@ -1562,7 +1562,8 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
if (first_len) if (first_len)
{ {
gfc_add_modify (&se->pre, first_len_val, gfc_add_modify (&se->pre, first_len_val,
se->string_length); fold_convert (TREE_TYPE (first_len_val),
se->string_length));
first_len = false; first_len = false;
} }
else else
...@@ -1571,7 +1572,9 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc, ...@@ -1571,7 +1572,9 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
length. */ length. */
tree cond = fold_build2_loc (input_location, NE_EXPR, tree cond = fold_build2_loc (input_location, NE_EXPR,
logical_type_node, first_len_val, logical_type_node, first_len_val,
se->string_length); fold_convert (TREE_TYPE
(first_len_val),
se->string_length));
gfc_trans_runtime_check gfc_trans_runtime_check
(true, false, cond, &se->pre, &expr->where, (true, false, cond, &se->pre, &expr->where,
"Different CHARACTER lengths (%ld/%ld) in array constructor", "Different CHARACTER lengths (%ld/%ld) in array constructor",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment