]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/58593 (internal compiler error: in gfc_conv_string_tmp, at fortran...
authorTobias Burnus <burnus@net-b.de>
Wed, 2 Oct 2013 21:02:14 +0000 (23:02 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Wed, 2 Oct 2013 21:02:14 +0000 (23:02 +0200)
2013-10-02  Tobias Burnus  <burnus@net-b.de>

        PR fortran/58593
        * trans-expr.c (gfc_conv_string_tmp): Fix obtaining
        the byte size of a single character.

2013-10-02  Tobias Burnus  <burnus@net-b.de>

        PR fortran/58593
        * gfortran.dg/char_length_19.f90: New.

From-SVN: r203135

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

index 71b1ffa8bf1103a83749a47619c3d71162a9305e..4463ecd84dced8852f5feae28452031b9ad6f151 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-02  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/58593
+       * trans-expr.c (gfc_conv_string_tmp): Fix obtaining
+       the byte size of a single character.
+
 2013-10-01  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/58579
index 67c8045decf2fa4c09268d63c25523a42cba4a61..a590ca18c803c4a6748e84de7bc71dbf64026257 100644 (file)
@@ -2357,8 +2357,9 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len)
       var = gfc_create_var (type, "pstr");
       gcc_assert (POINTER_TYPE_P (type));
       tmp = TREE_TYPE (type);
-      gcc_assert (TREE_CODE (tmp) == ARRAY_TYPE);
-      tmp = TYPE_SIZE_UNIT (TREE_TYPE (tmp));
+      if (TREE_CODE (tmp) == ARRAY_TYPE)
+        tmp = TREE_TYPE (tmp);
+      tmp = TYPE_SIZE_UNIT (tmp);
       tmp = fold_build2_loc (input_location, MULT_EXPR, size_type_node,
                            fold_convert (size_type_node, len),
                            fold_convert (size_type_node, tmp));
index ec43cc5e021000ccce2d3783c31f77a711224bff..4b7c6ee55d90e91d81eee1428ea8c7321e1c69f4 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-02  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/58593
+       * gfortran.dg/char_length_19.f90: New.
+
 2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58535
diff --git a/gcc/testsuite/gfortran.dg/char_length_19.f90 b/gcc/testsuite/gfortran.dg/char_length_19.f90
new file mode 100644 (file)
index 0000000..e52d018
--- /dev/null
@@ -0,0 +1,44 @@
+! { dg-do compile }
+!
+! PR fortran/58579
+!
+! Contributed by Joost VandeVondele
+!
+! Was ICEing before due to the patch for PR 58593
+!
+  subroutine test
+    CHARACTER(len=20)                        :: tmpStr
+    CHARACTER(len=20, kind=4)                :: tmpStr4
+    INTEGER :: output_unit=6
+       WRITE (UNIT=output_unit,FMT="(T2,A,T61,A20)")&
+         "DFT| Self-interaction correction (SIC)",ADJUSTR(TRIM(tmpstr))
+       WRITE (UNIT=output_unit,FMT="(T2,A,T61,A20)")&
+         4_"DFT| Self-interaction correction (SIC)",ADJUSTR(TRIM(tmpstr4))
+   END
+
+!
+! PR fortran/58593
+! Contributed by Albert Bartok
+!
+! The PR was overallocating memory. I placed it here to check for a
+! variant of the test case above, which takes a slightly differnt code
+! patch. Thus, its purpose is just to ensure that it won't ICE.
+!
+program test_char
+
+   implicit none
+   integer :: i
+
+   read*, i
+   print*, trim(test(i))
+
+   contains
+
+      function test(i)
+         integer, intent(in) :: i
+         character(len=i) :: test
+
+         test(1:1) = "A"
+      endfunction test
+
+endprogram test_char