* Possible patch for 62242
@ 2015-07-31 8:19 Louis Krupp
0 siblings, 0 replies; only message in thread
From: Louis Krupp @ 2015-07-31 8:19 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1567 bytes --]
As far as I can tell, the problem in 62242 (and possibly 62246) is with a string array constructor trying to deal with an array element whose value is a character function that is described in an interface block and which has an assumed-length result. I can't claim more than a superficial understanding of the code, but this patch seems to work. I ran make check-fortran, and I saw no regressions.
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (revision 226427)
+++ gcc/fortran/ChangeLog (working copy)
@@ -1877,6 +1877,12 @@
* interface.c (is_procptr_result): New function to check if an
expression is a procedure-pointer result.
(compare_actual_formal): Use it.
+
+2015_07-31
+
+ PR fortran/62242
+ * trans-array.c (gfc_add_loop_ss_code): String array constructor:
+ Don't try to convert string length unless it's constant.
^L
Copyright (C) 2015 Free Software Foundation, Inc.
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 226427)
+++ gcc/fortran/trans-array.c (working copy)
@@ -2589,7 +2589,8 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss
if (expr->ts.type == BT_CHARACTER
&& ss_info->string_length == NULL
&& expr->ts.u.cl
- && expr->ts.u.cl->length)
+ && expr->ts.u.cl->length
+ && expr->ts.u.cl->length->expr_type == EXPR_CONSTANT)
{
gfc_init_se (&se, NULL);
gfc_conv_expr_type (&se, expr->ts.u.cl->length,
[-- Attachment #2: string_array_constructor_1.f90 --]
[-- Type: application/octet-stream, Size: 771 bytes --]
! { dg-do compile }
! PR fortran/62242
! Array constructor with an array element whose value is a
! character function that is described in an interface block and which
! has an assumed-length result
module gfbug
implicit none
INTERFACE
function UpperCase(string) result(upper)
character(*), intent(IN) :: string
character(LEN(string)) :: upper
end function
function f2(string) result(upper)
character(*), intent(IN) :: string
character(5) :: upper
end function
END INTERFACE
contains
subroutine s1
character(5) c
character(5), dimension(1) :: ca
ca = (/f2(c)/) ! This compiles
ca = (/Uppercase(c)/) ! This gets an ICE
end subroutine
end module gfbug
[-- Attachment #3: string_array_constructor_2.f90 --]
[-- Type: application/octet-stream, Size: 1280 bytes --]
! { dg-do run }
! PR fortran/62242
! Array constructor with an array element whose value is a
! character function that is described in an interface block and which
! has an assumed-length result
module gfbug
implicit none
INTERFACE
function UpperCase(string) result(upper)
character(*), intent(IN) :: string
character(LEN(string)) :: upper
end function
function f2(string) result(upper)
character(*), intent(IN) :: string
character(5) :: upper
end function
END INTERFACE
contains
subroutine s1
character(5) c
character(5), dimension(1) :: ca
character(5), dimension(1) :: cb
c = "12345"
ca = (/f2(c)/) ! This works
!print *, ca(1)
cb = (/Uppercase(c)/) ! This gets an ICE
if (ca(1) .ne. cb(1)) then
call abort()
end if
!print *, ca(1)
end subroutine
end module gfbug
function UpperCase(string) result(upper)
character(*), intent(IN) :: string
character(LEN(string)) :: upper
upper = string
end function
function f2(string) result(upper)
character(*), intent(IN) :: string
character(5) :: upper
upper = string
end function
program main
use gfbug
call s1
end program
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-31 7:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-31 8:19 Possible patch for 62242 Louis Krupp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).