re PR fortran/36265 (character issue with gfortran)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 19 May 2008 15:57:28 +0000 (15:57 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 19 May 2008 15:57:28 +0000 (15:57 +0000)
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.

From-SVN: r135576

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/char_length_11.f90 [new file with mode: 0644]

index 3b1617eed65baf7e02c3ddda01cf02ded000bbe1..436142879dab18c08137cbb2262aec3bc1bb3eb9 100644 (file)
@@ -1,3 +1,9 @@
+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
index 482e8b14ff2ef6dc3b528f8365f24be028dcf2ca..6deaad65f04a380e695d9df5dff5f2125a740a2d 100644 (file)
@@ -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);
     }
index e334077a0a5ee549f7464a60f0ec1461b6582a3a..8da6d5f1622961f2df1970a148e85d893f8bc7db 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-19  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/36265
+       * gfortran.dg/char_length_11.f90: New test.
+
 2008-05-19  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        * gfortran.dg/widechar_intrinsics_5.f90: Add dg-do directive and
diff --git a/gcc/testsuite/gfortran.dg/char_length_11.f90 b/gcc/testsuite/gfortran.dg/char_length_11.f90
new file mode 100644 (file)
index 0000000..e745c12
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do compile }
+
+  character(len=*), parameter :: s = "foo"
+  write (*,*) adjustr(s(:))
+end