OSDN Git Service

2008-12-14 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 14 Dec 2008 16:00:25 +0000 (16:00 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 14 Dec 2008 16:00:25 +0000 (16:00 +0000)
PR fortran/35937
* trans-expr.c (gfc_finish_interface_mapping): Fold convert the
character length to gfc_charlen_type_node.

2008-12-14  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/35937
* gfortran.dg/char_length_14.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142750 138bc75d-0d04-0410-961f-82ee72b054a4

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

index db1fe42..ad49481 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-14  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/35937
+       * trans-expr.c (gfc_finish_interface_mapping): Fold convert the
+       character length to gfc_charlen_type_node.
+
 2008-12-12  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/36355
index 4ecfa08..4a84234 100644 (file)
@@ -1830,7 +1830,7 @@ gfc_finish_interface_mapping (gfc_interface_mapping * mapping,
        gfc_apply_interface_mapping_to_expr (mapping, expr);
        gfc_init_se (&se, NULL);
        gfc_conv_expr (&se, expr);
-
+       se.expr = fold_convert (gfc_charlen_type_node, se.expr);
        se.expr = gfc_evaluate_now (se.expr, &se.pre);
        gfc_add_block_to_block (pre, &se.pre);
        gfc_add_block_to_block (post, &se.post);
index 4cd90f0..0ff2a04 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-14  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/35937
+       * gfortran.dg/char_length_14.f90: New test.
+
 2008-12-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libfortran/38504
diff --git a/gcc/testsuite/gfortran.dg/char_length_14.f90 b/gcc/testsuite/gfortran.dg/char_length_14.f90
new file mode 100644 (file)
index 0000000..5827dd9
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do run }\r
+! PR35937, in which letting the length of 'c' to kind = 8 would\r
+! screw up the interface and would cause an ICE. Note that this is\r
+! actually the example of comment #4.\r
+!\r
+! Contributed by Thomas Koenig <tkoenig@gcc.gnu.org>\r
+!\r
+program main\r
+  implicit none\r
+  if (f5 ('1') .ne. "a") call abort\r
+  if (len (f5 ('1')) .ne. 1) call abort\r
+  if (f5 ('4') .ne. "abcd") call abort\r
+  if (len (f5 ('4')) .ne. 4) call abort\r
+contains\r
+  function f5 (c)\r
+    character(len=1_8) :: c\r
+    character(len=scan('123456789', c)) :: f5\r
+    integer :: i\r
+    do i = 1, len (f5)\r
+       f5(i:i) = char (i+96)\r
+    end do\r
+  end function f5\r
+end program main\r