From patchwork Wed Jun 12 20:38:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 250878 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 17DD42C009A for ; Thu, 13 Jun 2013 06:39:30 +1000 (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=iBhvybkVd+tdsA8G4O/FTf0nLua6YOqbQTDOsq0w1yVsJD 24E91zFbZRZCCajU6O/sK0V3zBoYJQcaVM5UOFdS1YZYHmhp/Tjc5UiUjyLnOATj CKg/R1lRyVmsRIj940zq6nefWGqmYinn17cktwCYAxMhCA50frhmAbe2X7Zfw= 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=ZMMuQPv0J7TVJ7DhYz+S8JKqZW8=; b=gZudlgmRdaMBNrX6j+D4 fAs+b4fQfHs8LRZeCTSVHS2AELimVvtzsGDsn5/9pfcsqMTA7faskF2Rjx2eQKD1 G37Iij+ZqkO8BnTCZ0i4KJXCNGkOVhefV+dgVCdQM5GjaQTviaPOjWkXuv1Rz3Q6 QbZ9ZxO1a1d+aJW42vL31qs= Received: (qmail 5799 invoked by alias); 12 Jun 2013 20:39:24 -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 5774 invoked by uid 89); 12 Jun 2013 20:39:23 -0000 X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from smtp23.services.sfr.fr (HELO smtp23.services.sfr.fr) (93.17.128.22) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 12 Jun 2013 20:39:22 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2314.sfr.fr (SMTP Server) with ESMTP id 19AA97000125; Wed, 12 Jun 2013 22:39:20 +0200 (CEST) Received: from [192.168.1.58] (126.183.72.86.rev.sfr.net [86.72.183.126]) by msfrf2314.sfr.fr (SMTP Server) with ESMTP id B6AE57000158; Wed, 12 Jun 2013 22:39:19 +0200 (CEST) X-SFR-UUID: 20130612203919748.B6AE57000158@msfrf2314.sfr.fr Message-ID: <51B8DC30.9020100@sfr.fr> Date: Wed, 12 Jun 2013 22:38:08 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130530 Thunderbird/17.0.6 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, fortran] PR 49074 ICE on defined assignment with class arrays. X-Virus-Found: No Hello, this is a fix for PR49074, where the temporary created by gfc_conv_elemental_dependencies was leading to an ICE because it didn't have the array reference expected by the scalarization code. There was a bypass in gfc_conv_procedure_call avoiding exactly this problem, but it is not reached when polymorphic entities are involved. To avoid duplicating that, the patch proposed here adds support for null references in gfc_conv_variable and removes the gfc_conv_procedure_call bypass. The patch also removes a useless reference walk in gfc_conv_variable. The test is the PR's; it's a runtime test as this area of the compiler doesn't get much coverage from the test-suite. Regression tested on x86_64-unknown-linux-gnu. OK for trunk? Mikael 2013-06-12 Mikael Morin PR fortran/49074 * trans-expr.c (gfc_conv_variable): Don't walk the reference chain. Handle NULL references. (gfc_conv_procedure_call): Remove code handling NULL references. 2013-06-12 Mikael Morin PR fortran/49074 * gfortran.dg/typebound_assignment_5.f03: New. ! { dg-do run } ! ! PR fortran/49074 ! ICE on defined assignment with class arrays. module foo type bar integer :: i contains generic :: assignment (=) => assgn_bar procedure, private :: assgn_bar end type bar contains elemental subroutine assgn_bar (a, b) class (bar), intent (inout) :: a class (bar), intent (in) :: b select type (b) type is (bar) a%i = b%i end select return end subroutine assgn_bar end module foo program main use foo type (bar), allocatable :: foobar(:) allocate (foobar(2)) foobar = [bar(1), bar(2)] if (any(foobar%i /= [1, 2])) call abort end program diff --git a/trans-expr.c b/trans-expr.c index 9d07345..bd8886c 100644 --- a/trans-expr.c +++ b/trans-expr.c @@ -1761,9 +1761,12 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) /* A scalarized term. We already know the descriptor. */ se->expr = ss_info->data.array.descriptor; se->string_length = ss_info->string_length; - for (ref = ss_info->data.array.ref; ref; ref = ref->next) - if (ref->type == REF_ARRAY && ref->u.ar.type != AR_ELEMENT) - break; + ref = ss_info->data.array.ref; + if (ref) + gcc_assert (ref->type == REF_ARRAY + && ref->u.ar.type != AR_ELEMENT); + else + gfc_conv_tmp_array_ref (se); } else { @@ -4041,23 +4044,11 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, gfc_init_se (&parmse, se); parm_kind = ELEMENTAL; - if (ss->dimen > 0 && e->expr_type == EXPR_VARIABLE - && ss->info->data.array.ref == NULL) - { - gfc_conv_tmp_array_ref (&parmse); - if (e->ts.type == BT_CHARACTER) - gfc_conv_string_parameter (&parmse); - else - parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr); - } - else - { - gfc_conv_expr_reference (&parmse, e); - if (e->ts.type == BT_CHARACTER && !e->rank - && e->expr_type == EXPR_FUNCTION) - parmse.expr = build_fold_indirect_ref_loc (input_location, - parmse.expr); - } + gfc_conv_expr_reference (&parmse, e); + if (e->ts.type == BT_CHARACTER && !e->rank + && e->expr_type == EXPR_FUNCTION) + parmse.expr = build_fold_indirect_ref_loc (input_location, + parmse.expr); if (fsym && fsym->ts.type == BT_DERIVED && gfc_is_class_container_ref (e))