This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix wide-char regressions, wrong types from the FE
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Sun, 31 Aug 2008 15:37:06 +0200 (CEST)
- Subject: [PATCH] Fix wide-char regressions, wrong types from the FE
The FE generates multiplications with mismatched types.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the trunk.
Richard.
2008-08-31 Richard Guenther <rguenther@suse.de>
* trans-expr.c (gfc_trans_string_copy): Use the correct types
to compute slen and dlen.
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 139823)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_trans_string_copy (stmtblock_t * blo
*** 3066,3075 ****
/* For non-default character kinds, we have to multiply the string
length by the base type size. */
chartype = gfc_get_char_type (dkind);
! slen = fold_build2 (MULT_EXPR, size_type_node, slen,
! TYPE_SIZE_UNIT (chartype));
! dlen = fold_build2 (MULT_EXPR, size_type_node, dlen,
! TYPE_SIZE_UNIT (chartype));
if (dlength)
dest = fold_convert (pvoid_type_node, dest);
--- 3066,3077 ----
/* For non-default character kinds, we have to multiply the string
length by the base type size. */
chartype = gfc_get_char_type (dkind);
! slen = fold_build2 (MULT_EXPR, size_type_node,
! fold_convert (size_type_node, slen),
! fold_convert (size_type_node, TYPE_SIZE_UNIT (chartype)));
! dlen = fold_build2 (MULT_EXPR, size_type_node,
! fold_convert (size_type_node, dlen),
! fold_convert (size_type_node, TYPE_SIZE_UNIT (chartype)));
if (dlength)
dest = fold_convert (pvoid_type_node, dest);