This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch,committed] Fix PR36265, widechar regression
- From: FX <fxcoudert at gmail dot com>
- To: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 19 May 2008 16:57:31 +0100
- Subject: [patch,committed] Fix PR36265, widechar regression
My widechar patch broke compilation of cp2k. The fix is simple, and I
actually had it in my tree at some point during the writing of the
last, large patch, but I removed it for simplification's sake after I
discovered that it was never exercised in all the testsuite. Well, it
looks like it can actually happen, so I'm putting it back.
Committed after regtesting on x86_64-linux, added a short testcase
reduced from cp2k. cp2k now compiles fine again.
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>
PR fortran/36265
* gfortran.dg/char_length_11.f90: New test.
Index: fortran/trans-expr.c
===================================================================
--- fortran/trans-expr.c (revision 135574)
+++ fortran/trans-expr.c (working copy)
@@ -977,7 +977,12 @@ gfc_conv_string_tmp (gfc_se * se, tree t
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);
}
Index: testsuite/gfortran.dg/char_length_11.f90
===================================================================
--- testsuite/gfortran.dg/char_length_11.f90 (revision 0)
+++ testsuite/gfortran.dg/char_length_11.f90 (revision 0)
@@ -0,0 +1,5 @@
+! { dg-do compile }
+
+ character(len=*), parameter :: s = "foo"
+ write (*,*) adjustr(s(:))
+end
FX
--
FX Coudert
http://www.homepages.ucl.ac.uk/~uccafco/