From patchwork Wed Dec 19 23:29:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 207550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 26B2D2C0090 for ; Thu, 20 Dec 2012 10:30:00 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1356564601; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=KEtcOfY 1+5NTKmSrskVP2Z0Y7QM=; b=o27KvLhfUAhy0eVP2zn3WM0l/1W/lgQlCoToPgL 3hoF09t4vIuIOM+neeI5yk6PDlRkdWCP7PYKQUYUTIKUxQ8cJMP8enRMqUlLXsks kW2eamm0YTGTDt/hsmgY9DW2pcvq90QQHXeGq7k6vnvfs1qiPhDqQkd2afr12l++ yYHI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=vfWZmcN1eJA5Ol0hHC2xNM+a7ToVXWPU0/E4PiJDoJbs2QwkJAA9JRH1EdnXJP lCDM9e6V+ryEJORoApV8R1C2eM1UCqwtn3vGBZJx6oiiz+yz6o/CVqA4rRAlj9J/ YlVlwoV//FtNjxl3hOiTLpmRSdeXxvRVml8FAtgmMKwUs=; Received: (qmail 18275 invoked by alias); 19 Dec 2012 23:29:54 -0000 Received: (qmail 18258 invoked by uid 22791); 19 Dec 2012 23:29:54 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_KN X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Dec 2012 23:29:49 +0000 Received: from archimedes.net-b.de (port-92-195-17-106.dynamic.qsc.de [92.195.17.106]) by mx01.qsc.de (Postfix) with ESMTP id C66913CE97; Thu, 20 Dec 2012 00:29:47 +0100 (CET) Message-ID: <50D24DEB.9090802@net-b.de> Date: Thu, 20 Dec 2012 00:29:47 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR54818 - Fix ICE with TRANSFER to char Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org TRANSFER(..., "string") created on x86-64 an integer(8) string length; that lead to a tree-checking ICE but also might pass the wrong type in 'call sub(transfer(233," ")'. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2012-12-20 Tobias Burnus PR fortran/54818 * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Ensure that the string length if of type gfc_charlen_type_node. 2012-12-20 Tobias Burnus PR fortran/54818 * gfortran.dg/transfer_intrinsic_4.f: New. diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 4f74c3f..b1e6a2e 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -5662,7 +5662,7 @@ scalar_transfer: gfc_add_expr_to_block (&se->pre, tmp); se->expr = tmpdecl; - se->string_length = dest_word_len; + se->string_length = fold_convert (gfc_charlen_type_node, dest_word_len); } else { diff --git a/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f b/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f new file mode 100644 index 0000000..4173afd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f @@ -0,0 +1,27 @@ +! { dg-do compile } +! +! PR fortran/54818 +! +! Contributed by Scott Pakin +! + subroutine broken ( name1, name2, bmix ) + + implicit none + + integer, parameter :: i_knd = kind( 1 ) + integer, parameter :: r_knd = selected_real_kind( 13 ) + + character(len=8) :: dum + character(len=8) :: blk + real(r_knd), dimension(*) :: bmix, name1, name2 + integer(i_knd) :: j, idx1, n, i + integer(i_knd), external :: nafix + + write (*, 99002) name1(j), + & ( adjustl( + & transfer(name2(nafix(bmix(idx1+i),1)),dum)//blk + & //blk), bmix(idx1+i+1), i = 1, n, 2 ) + +99002 format (' *', 10x, a8, 8x, 3(a24,1pe12.5,',',6x)) + + end subroutine broken