From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97880 invoked by alias); 31 Jul 2015 07:08:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97861 invoked by uid 89); 31 Jul 2015 07:08:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: sender153-mail.zoho.com Received: from sender153-mail.zoho.com (HELO sender153-mail.zoho.com) (74.201.84.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 31 Jul 2015 07:08:43 +0000 Received: from mail.zoho.com by mx.zohomail.com with SMTP id 143832652037711.783357922020855; Fri, 31 Jul 2015 00:08:40 -0700 (PDT) Received: from [209.169.24.247] by mail.zoho.com with HTTP;Fri, 31 Jul 2015 00:08:40 -0700 (PDT) Date: Fri, 31 Jul 2015 08:19:00 -0000 From: Louis Krupp To: Message-ID: <14ee2f0fa04.1099515e221024.4229538263700683629@zoho.com> Subject: Possible patch for 62242 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_17584_1583880408.1438326520321" User-Agent: Zoho Mail X-Zoho-Virus-Status: 1 X-SW-Source: 2015-07/txt/msg02621.txt.bz2 ------=_Part_17584_1583880408.1438326520321 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 1567 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, ------=_Part_17584_1583880408.1438326520321 Content-Type: application/octet-stream; name=string_array_constructor_1.f90 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=string_array_constructor_1.f90 Content-length: 771 ! { 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 ------=_Part_17584_1583880408.1438326520321 Content-Type: application/octet-stream; name=string_array_constructor_2.f90 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=string_array_constructor_2.f90 Content-length: 1280 ! { 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 ------=_Part_17584_1583880408.1438326520321--