summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-19 15:57:28 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-19 15:57:28 +0000
commit51bd64793975eddff040d7f96228a9141a97ac97 (patch)
tree7f3c89b56ee917a3b75582814978b80e0823bad4 /gcc/fortran
parent724ad675e737e48a5b350e06c53fe2430f024134 (diff)
downloadgcc-51bd64793975eddff040d7f96228a9141a97ac97.tar.gz
PR fortran/36265
* trans-expr.c (gfc_conv_string_tmp): Pick the correct type for the temporary variable. * gfortran.dg/char_length_11.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135576 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-expr.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3b1617eed65..436142879da 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2008-05-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+ PR fortran/36265
+ * trans-expr.c (gfc_conv_string_tmp): Pick the correct type for
+ the temporary variable.
+
+2008-05-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
* simplify.c (gfc_simplify_dble, gfc_simplify_real): Initialize
result variable to avoid warnings.
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 482e8b14ff2..6deaad65f04 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -977,7 +977,12 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len)
tmp = fold_build2 (MINUS_EXPR, gfc_charlen_type_node, len,
build_int_cst (gfc_charlen_type_node, 1));
tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node, tmp);
- tmp = build_array_type (TREE_TYPE (TREE_TYPE (type)), tmp);
+
+ if (TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
+ tmp = build_array_type (TREE_TYPE (TREE_TYPE (type)), tmp);
+ else
+ tmp = build_array_type (TREE_TYPE (type), tmp);
+
var = gfc_create_var (tmp, "str");
var = gfc_build_addr_expr (type, var);
}