From patchwork Mon Apr 4 09:48:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 605820 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qdnHz6Yrcz9s4q for ; Mon, 4 Apr 2016 19:49:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=VOXAfoG8; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=t2vGnHEFagTsmuJI AjvjZOM21hso93zrxwWEUd+8TsVvKz81yELcVTYJh+RcbCHfibkvp8RcPfYm+jQG M1T4xRUjp/nNQsYRXnPnBvUyL1zY7v892lNQi86kKLxO2toEO6s95WDZYTAdsw7F Gj2kcUPy2FE9Mg7VvLnsfjOMRm8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=chUgRpEFXTnfPn8pITsxWb lQC8A=; b=VOXAfoG8TMdgfnW1sKBIIKSlQIYaE3pRWnLiPvh9KSTonGLFuW221V UCqOa7C6PbYTYD9ynruVHY6ineDo/rLxaU2NAifsw/UNCijX0srnL+sYTG1RCbJB 6XAZMjPo6AxwjLpOwwXufHIMdA2lIbJVW3AwXOUuIqCznrtWoY76o= Received: (qmail 21090 invoked by alias); 4 Apr 2016 09:48:53 -0000 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 Received: (qmail 21054 invoked by uid 89); 4 Apr 2016 09:48:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=existent, arbeitskopie, Arbeitskopie, U*jvdelisle X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 04 Apr 2016 09:48:41 +0000 Received: from vepi2 ([88.77.160.134]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MWxtA-1bIw640daW-00W0TN; Mon, 04 Apr 2016 11:48:36 +0200 Date: Mon, 4 Apr 2016 11:48:34 +0200 From: Andre Vehreschild To: Jerry DeLisle Cc: GCC-Patches-ML , GCC-Fortran-ML Subject: Re: [Fortran, Patch, pr66911, gcc-5, v1] ICE on allocate character with source as a derived type component Message-ID: <20160404114834.1112faac@vepi2> In-Reply-To: <57016D77.7030501@charter.net> References: <20160403173357.1a2b03b7@vepi2> <57016D77.7030501@charter.net> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:VcCyzD0cksU=:orT5k9Ob5YVkGIA5OUlcQZ Uha1fysxbFpgXEpb7rXPPmx8KlSx7ctfpG54J2Pwpv3NUBXd9aIH2WNpzlkggZHaOjCVcLyCR Y+9wJaJpjXC8pKZL9SsPcfliR4sSRE6cGPDC34pGBtmFGd6LOlZCrvncksbWdj6lAPWUCSBzq EQ1P0alfnyXp97nGyCNHXwjqu/puQRUBi1nKTpqOu7PU0hyWxmP5IYt9iHh66wFgAC9rcA8VG g3ckKdXHyZl+QTIxNV/gbZbsXl/Y6hx6Cxrizr+FLtvsJx7Kb4x4OaNORU5vZSxA+xWqySPnm zKj7wHJaHPB8NjrpWM6webRi/a1ZvLJwpfy6tFKnizPXG+eE/uVHqx53iQ0Q0Ga4m/OErF9ds ww0V3eMOwh4dbRyL6GGKhF+ZIvyFsAGyDlCEFdApFshQMa+uT94JDYau5IbzbM5Nvz34eKKcj mAJiDO+dyJsd0gG4+BDXvMAmXFlVWGVS3jsOguNYT/tLe2Vk866vpXsGzJq5XOtLyw4ogC7np 5TJkiTA8fyqxjFk9BUMVLBxjnkbeH5XUDH8sSIp3eyC9nMex7xeLRAaVtpmFR5RHETzrs2GaM kMg5QNl/W1/TL69tje6VCfX0LHMaJWmOEgJhrLAAcwVBfiddY3OVNeFGGnVtUT00sBwURLS7H 8gF/+kEdQmSuE6u/QVV446dRAaeGEEjpF4fwvVKkwlyIWurkcZpKByUXuXnZfUn8kyFMo7IgH ECT5GDoPz1L8h97qFqhMgkqU7mHu/rH7aF3bFC9QYnCdXyEFcJPi/JP2mUY= Hi Jerry, thank you for the review. Committed as r234712 to gcc-5-branch. Regards, Andre On Sun, 3 Apr 2016 12:22:31 -0700 Jerry DeLisle wrote: > On 04/03/2016 08:33 AM, Andre Vehreschild wrote: > > Hi all, > > > > attached patch fixes the ICE when using a deferred length char array as > > source= expression in an allocate for complicated source= expressions. > > Before the patch the compiler was relying on having the string length > > available in the ts of the expression, but when the expression is > > sufficiently complicated it is not set there. In trunk the problem does > > not arise, because the source= expression is evaluated in more cases. > > In gcc-5 this is not available without doing a major rewrite of the > > allocate() statement's conv-routine. Therefore this small portion of > > extra code reliably does the trick and takes the string_length from the > > se.string_length now. > > > > Bootstrapped and regtested ok on x86_64-linux-gnu/F23. Ok for > > gcc-5-branch? > > > > Regards, > > Andre > > > > Yes, OK > > Thanks for your work. > > Jerry Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 234711) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,10 @@ +2016-04-04 Andre Vehreschild + + PR fortran/66911 + * trans-stmt.c (gfc_trans_allocate): Get the deferred length of an + expression by converting the expression when the length is not set + in the symbol's ts. + 2016-04-04 Andre Vehreschild PR fortran/65795 Index: gcc/fortran/trans-stmt.c =================================================================== --- gcc/fortran/trans-stmt.c (Revision 234710) +++ gcc/fortran/trans-stmt.c (Arbeitskopie) @@ -5536,14 +5536,23 @@ if (expr3_len == NULL_TREE && code->expr3->ts.type == BT_CHARACTER) { + gfc_init_se (&se, NULL); if (code->expr3->ts.u.cl && code->expr3->ts.u.cl->length) { - gfc_init_se (&se, NULL); gfc_conv_expr (&se, code->expr3->ts.u.cl->length); gfc_add_block_to_block (&block, &se.pre); expr3_len = gfc_evaluate_now (se.expr, &block); } + else + { + /* The string_length is not set in the symbol, which prevents + it being set in the ts. Deduce it by converting expr3. */ + gfc_conv_expr (&se, code->expr3); + gfc_add_block_to_block (&block, &se.pre); + gcc_assert (se.string_length); + expr3_len = gfc_evaluate_now (se.string_length, &block); + } gcc_assert (expr3_len); } /* For character arrays only the kind's size is needed, because Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 234711) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2016-04-04 Andre Vehreschild + + PR fortran/66911 + * gfortran.dg/deferred_character_16.f90: New test. + 2016-04-04 Andre Vehreschild PR fortran/65795 Index: gcc/testsuite/gfortran.dg/deferred_character_16.f90 =================================================================== --- gcc/testsuite/gfortran.dg/deferred_character_16.f90 (nicht existent) +++ gcc/testsuite/gfortran.dg/deferred_character_16.f90 (Arbeitskopie) @@ -0,0 +1,24 @@ +! { dg-do run } + +program truc +implicit none + +type t_env_table + character(len=:), allocatable :: key +end type + +type(t_env_table), dimension(:), allocatable :: environment_table + +character(len=:), allocatable :: s + +allocate(environment_table(1)) +environment_table(1)%key='tt' + +allocate(s, source=environment_table(1)%key) + +if ( .not. allocated(s) ) call abort() +if ( s /= "tt" ) call abort() +if ( len(s) /= 2 ) call abort() +!print *, 's:"', s, '" derived:"',environment_table(1)%key,'"' + +end program