From patchwork Mon Mar 24 23:59:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 333197 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 A277214008C for ; Tue, 25 Mar 2014 10:59:45 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=UiDKYKkn9s3Y5Fg913/bDA2T7ysnY1hqshsjbjJEqeMh3c seShe3kg6d0aFS5Ol2ZfBUe0n50YTLA4p8vuBiYUTRPEUU+RtY99CUaPm8rRacRx A3wMQ/UnAVCkKHbL52YWbx/yvodRFYM87TCKH2m7m+NR4fzOlCn1p61mF7Kec= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Og0ln8hgOgkpOr9CFiuVdBBk/MQ=; b=Ty7Lbi2baZ7t01XwJgLX r4cMDO7BbWM8ncQ0tTMiB35tivJw9KfarkpQ+cObPgA7MKeq1G9v24P3kWXYH6ED KGn0PMRe6ZYV0SiwwwtNAllrQIGQIwrl/qfSKtHiUPHZthDVh2WmG9nXHi6jsqjl AaK6w/vOXhnTOPZGStyC3g0= Received: (qmail 504 invoked by alias); 24 Mar 2014 23:59:31 -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 475 invoked by uid 89); 24 Mar 2014 23:59:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx01.qsc.de Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 24 Mar 2014 23:59:29 +0000 Received: from tux.net-b.de (port-92-194-244-210.dynamic.qsc.de [92.194.244.210]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPSA id 535833D042; Tue, 25 Mar 2014 00:59:25 +0100 (CET) Message-ID: <5330C6DD.60503@net-b.de> Date: Tue, 25 Mar 2014 00:59:25 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gcc-patches , gfortran Subject: [Patch, Fortran] PR58880 - Fix ICE with finalizers Hi all, this patch fixes a problem with the conversion of scalars to descriptors. There one assigns the address of the scalar to the base_address field of the descriptor. The ICE occurred when the RHS (the scalar) wasn't a pointer. It does not fully solve the PR as for some reasons the finalization wrapper is not generated - which causes link errors or ICEs (see PR). Build and regtested on x86-64-gnu-linux. OK for the (4.9) trunk? Tobias 2014-03-25 Tobias Burnus PR fortran/58880 * trans-expr.c (gfc_conv_scalar_to_descriptor): Fix handling of nonpointers. 2014-03-25 Tobias Burnus PR fortran/58880 * gfortran.dg/finalize_24.f90: New. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index f5350bb..30931a3 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -69,14 +69,16 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr) type = get_scalar_to_descriptor_type (scalar, attr); desc = gfc_create_var (type, "desc"); DECL_ARTIFICIAL (desc) = 1; + + if (!POINTER_TYPE_P (TREE_TYPE (scalar))) + scalar = gfc_build_addr_expr (NULL_TREE, scalar); gfc_add_modify (&se->pre, gfc_conv_descriptor_dtype (desc), gfc_get_dtype (type)); gfc_conv_descriptor_data_set (&se->pre, desc, scalar); /* Copy pointer address back - but only if it could have changed and if the actual argument is a pointer and not, e.g., NULL(). */ - if ((attr.pointer || attr.allocatable) - && attr.intent != INTENT_IN && POINTER_TYPE_P (TREE_TYPE (scalar))) + if ((attr.pointer || attr.allocatable) && attr.intent != INTENT_IN) gfc_add_modify (&se->post, scalar, fold_convert (TREE_TYPE (scalar), gfc_conv_descriptor_data_get (desc))); diff --git a/gcc/testsuite/gfortran.dg/finalize_24.f90 b/gcc/testsuite/gfortran.dg/finalize_24.f90 new file mode 100644 index 0000000..2a21858 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/finalize_24.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! +! PR fortran/58880 +! +! Contributed by Andrew Benson +! + +module gn + type sl + integer, allocatable, dimension(:) :: lv + contains + final :: sld + end type sl + type :: nde + type(sl) :: r + end type nde +contains + subroutine ndm(s) + type(nde), intent(inout) :: s + type(nde) :: i + i=s + end subroutine ndm + subroutine sld(s) + implicit none + type(sl), intent(inout) :: s + return + end subroutine sld +end module gn