public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR 84740 Wrong string length type in bounds check
@ 2018-01-10 11:18 Janne Blomqvist
  2018-01-10 11:21 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Janne Blomqvist @ 2018-01-10 11:18 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Janne Blomqvist

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.
---
 gcc/fortran/trans-array.c | 7 +++++--
 1 file 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",
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-10 11:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 11:18 [PATCH] PR 84740 Wrong string length type in bounds check Janne Blomqvist
2018-01-10 11:21 ` Jakub Jelinek
2018-01-10 11:36   ` Janne Blomqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).