diff options
author | Tobias Burnus <burnus@net-b.de> | 2013-10-01 23:00:17 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2013-10-01 23:00:17 +0200 |
commit | 2df0e3c9cfdac71e2e8a06975aa8e7837ae6f58f (patch) | |
tree | 77a71af776b346009316a99ab36461f869d1ee32 /gcc/fortran/trans-expr.c | |
parent | 7902928918b076991f98ba43678cc287abb5f316 (diff) | |
download | gcc-2df0e3c9cfdac71e2e8a06975aa8e7837ae6f58f.zip gcc-2df0e3c9cfdac71e2e8a06975aa8e7837ae6f58f.tar.gz gcc-2df0e3c9cfdac71e2e8a06975aa8e7837ae6f58f.tar.bz2 |
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
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r-- | gcc/fortran/trans-expr.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 0ecfdfc..67c8045 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. */ |