re PR fortran/58579 (Memory allocation fails when calling character-valued function)

2013-10-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/58579
        * trans-expr.c (gfc_conv_string_tmp): Correctly obtain
        the byte size of a single character.

From-SVN: r203088
This commit is contained in:
Tobias Burnus 2013-10-01 23:00:17 +02:00 committed by Tobias Burnus
parent 7902928918
commit 2df0e3c9cf
2 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2013-10-01 Tobias Burnus <burnus@net-b.de>
PR fortran/58579
* trans-expr.c (gfc_conv_string_tmp): Correctly obtain
the byte size of a single character.
2013-09-27 Janne Blomqvist <jb@gcc.gnu.org> 2013-09-27 Janne Blomqvist <jb@gcc.gnu.org>
* intrinsic.texi (DATE_AND_TIME): Fix example. * intrinsic.texi (DATE_AND_TIME): Fix example.

View File

@ -2355,11 +2355,14 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len)
{ {
/* Allocate a temporary to hold the result. */ /* Allocate a temporary to hold the result. */
var = gfc_create_var (type, "pstr"); var = gfc_create_var (type, "pstr");
tmp = gfc_call_malloc (&se->pre, type, gcc_assert (POINTER_TYPE_P (type));
fold_build2_loc (input_location, MULT_EXPR, tmp = TREE_TYPE (type);
TREE_TYPE (len), len, gcc_assert (TREE_CODE (tmp) == ARRAY_TYPE);
fold_convert (TREE_TYPE (len), tmp = TYPE_SIZE_UNIT (TREE_TYPE (tmp));
TYPE_SIZE (type)))); 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); gfc_add_modify (&se->pre, var, tmp);
/* Free the temporary afterwards. */ /* Free the temporary afterwards. */