From: burnus Date: Tue, 1 Oct 2013 21:00:17 +0000 (+0000) Subject: 2013-10-01 Tobias Burnus X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e97b371e2dc6aadf0b6e66a57d17eccfe0f3829;p=thirdparty%2Fgcc.git 2013-10-01 Tobias Burnus PR fortran/58579 * trans-expr.c (gfc_conv_string_tmp): Correctly obtain the byte size of a single character. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203088 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ecdccab1c7cb..71b1ffa8bf11 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-10-01 Tobias Burnus + + PR fortran/58579 + * trans-expr.c (gfc_conv_string_tmp): Correctly obtain + the byte size of a single character. + 2013-09-27 Janne Blomqvist * intrinsic.texi (DATE_AND_TIME): Fix example. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 0ecfdfce4690..67c8045decf2 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2355,11 +2355,14 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len) { /* Allocate a temporary to hold the result. */ var = gfc_create_var (type, "pstr"); - tmp = gfc_call_malloc (&se->pre, type, - fold_build2_loc (input_location, MULT_EXPR, - TREE_TYPE (len), len, - fold_convert (TREE_TYPE (len), - TYPE_SIZE (type)))); + gcc_assert (POINTER_TYPE_P (type)); + tmp = TREE_TYPE (type); + gcc_assert (TREE_CODE (tmp) == ARRAY_TYPE); + tmp = TYPE_SIZE_UNIT (TREE_TYPE (tmp)); + tmp = fold_build2_loc (input_location, MULT_EXPR, size_type_node, + fold_convert (size_type_node, len), + fold_convert (size_type_node, tmp)); + tmp = gfc_call_malloc (&se->pre, type, tmp); gfc_add_modify (&se->pre, var, tmp); /* Free the temporary afterwards. */