PR 84740 Wrong string length type in bounds check
authorJanne Blomqvist <jb@gcc.gnu.org>
Wed, 10 Jan 2018 11:18:31 +0000 (13:18 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Wed, 10 Jan 2018 11:18:31 +0000 (13:18 +0200)
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

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c

index e19ed61698b0ddd80a62829c2dbf75b8e7df40cf..8ee13b1930f9e6ae76ffd366c3f2e1bc428b0a39 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        PR fortran/83742
index 474a7d1a84eeb4d9aa3244da6611fef451c2879d..8a0afe9101cc6ef5278c5f59af6c53a431527150 100644 (file)
@@ -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",