From: Paul Thomas Date: Fri, 7 Feb 2014 23:29:44 +0000 (+0000) Subject: re PR fortran/59906 (error: size of variable '' is too large) X-Git-Tag: releases/gcc-4.7.4~261 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8df0e6ee5d22905f2b8e4ce03033d98b4b8cafa;p=thirdparty%2Fgcc.git re PR fortran/59906 (error: size of variable '' is too large) 2014-02-08 Paul Thomas PR fortran/59906 * trans-array.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-08 Paul Thomas PR fortran/59906 * gfortran.dg/elemental_subroutine_9.f90 : New test From-SVN: r207617 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b3168179085b..98e1e7fea2be 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2014-02-08 Paul Thomas + + PR fortran/59906 + * trans-array.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-03 Janus Weil PR fortran/59941 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 4b701710f750..25340f58eea2 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2465,6 +2465,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)) diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index b54a28ed8fd2..89a3d5331c0c 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -5595,7 +5595,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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac13876f53c5..c9c7b8fe6f40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-08 Paul Thomas + + PR fortran/59906 + * gfortran.dg/elemental_subroutine_9.f90 : New test + 2014-02-04 Uros Bizjak 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 index 000000000000..8f574bf595e8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_subroutine_9.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! +! PR fortran/59906 +! +! Contributed by H Anlauf +! +! 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