]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/59906 (error: size of variable '<anonymous>' is too large)
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 7 Feb 2014 21:15:37 +0000 (21:15 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 7 Feb 2014 21:15:37 +0000 (21:15 +0000)
2014-02-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/59906
* trans-stmt.c (gfc_add_loop_ss_code): In the case of character
SS_REFERENCE, use gfc_conv_string_parameter to ensure that a
pointer to the string is stored.
* trans-expr.c (gfc_conv_expr_reference): Likewise, use
gfc_conv_string_parameter to ensure that a pointer to is passed
to the elemental function.

2014-02-07  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/59906
* gfortran.dg/elemental_subroutine_9.f90 : New test

From-SVN: r207613

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

index 2ec8e7fa5e3923e5baacde5b9c0c0547cd7cefd3..029a23f2f834b1bae30534380eb0e3622b115986 100644 (file)
@@ -1,3 +1,13 @@
+2014-02-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/59906
+       * trans-stmt.c (gfc_add_loop_ss_code): In the case of character
+       SS_REFERENCE, use gfc_conv_string_parameter to ensure that a
+       pointer to the string is stored.
+       * trans-expr.c (gfc_conv_expr_reference): Likewise, use
+       gfc_conv_string_parameter to ensure that a pointer to is passed
+       to the elemental function.
+
 2014-02-01  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/59414
index 2927b80d4447738076032bf8364bca45336e52f7..8da24a2578f15544b042d0ae1864c0e5e49c6841 100644 (file)
@@ -2487,6 +2487,11 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
                 a reference to the value.  */
              gfc_conv_expr (&se, expr);
            }
+
+         /* Ensure that a pointer to the string is stored.  */
+         if (expr->ts.type == BT_CHARACTER)
+           gfc_conv_string_parameter (&se);
+
          gfc_add_block_to_block (&outer_loop->pre, &se.pre);
          gfc_add_block_to_block (&outer_loop->post, &se.post);
          if (gfc_is_class_scalar_expr (expr))
index f1452fa423a30b6eea1eac91761abcce18064361..891717aca40052cceb2066fe6692a8c7da3c0307 100644 (file)
@@ -6342,7 +6342,13 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
       /* Returns a reference to the scalar evaluated outside the loop
         for this case.  */
       gfc_conv_expr (se, expr);
-      se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
+
+      if (expr->ts.type == BT_CHARACTER
+         && expr->expr_type != EXPR_FUNCTION)
+       gfc_conv_string_parameter (se);
+      else
+       se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
+
       return;
     }
 
index de7d6545dc1feb3a121fa66865904a248ecb10c9..11a388acf3aa3b801c6c3181fe83c462d136585b 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/59906
+       * gfortran.dg/elemental_subroutine_9.f90 : New test
+
 2014-02-04  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/elemental_subroutine_9.f90 b/gcc/testsuite/gfortran.dg/elemental_subroutine_9.f90
new file mode 100644 (file)
index 0000000..8f574bf
--- /dev/null
@@ -0,0 +1,39 @@
+! { dg-do run }
+!
+! PR fortran/59906
+!
+! Contributed by H Anlauf  <anlauf@gmx.de>
+!
+! Failed generate character scalar for scalarized loop for elemantal call.
+!
+program x
+  implicit none
+  call y('bbb')
+contains
+
+  subroutine y(str)
+    character(len=*), intent(in) :: str
+    character(len=len_trim(str)) :: str_aux
+    character(len=3) :: str3 = 'abc'
+
+    str_aux = str
+
+    ! Compiled but did not give correct result
+    if (any (str_cmp((/'aaa','bbb'/), str) .neqv. [.FALSE.,.TRUE.])) call abort
+
+    ! Did not compile
+    if (any (str_cmp((/'bbb', 'aaa'/), str_aux) .neqv. [.TRUE.,.FALSE.])) call abort
+
+    ! Verify patch
+    if (any (str_cmp((/'bbb', 'aaa'/), str3) .neqv. [.FALSE.,.FALSE.])) call abort
+    if (any (str_cmp((/'bbb', 'aaa'/), 'aaa') .neqv. [.FALSE.,.TRUE.])) call abort
+
+  end subroutine y
+
+  elemental logical function str_cmp(str1, str2)
+    character(len=*), intent(in) :: str1
+    character(len=*), intent(in) :: str2
+    str_cmp = (str1 == str2)
+  end function str_cmp
+
+end program x