From patchwork Fri Nov 1 15:56:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 287865 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 did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3457A2C0084 for ; Sat, 2 Nov 2013 02:56:52 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=eSstBsot21evf+pwk4kJAu2OEK7w2BfgR3ZPcijeOLokrM gNqF/Ld5YioALOp+Yz3lKuSzMrunW7Xj2XWdJmsf0FcCV+a6nbEPhrMgiimrjQIN TJeks7zqZ305XqLTFJHAEf+E5Lj6S+/mh7eYRNcdQ3hV/U3gGpguqBWmd/Fao= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=eFZkqBBtMFohprec2lD7tIt0pxY=; b=fZLN1hyRVFhJL6y48XBr bfta7jseF2+xab/wyZK9Pyut+huYFt2bGl6SxOoGDktLz9uzBnlQ0g3oiK5d+6T8 ERtHKITTWZdg1ZUiQw9IyJT0dRmlo6EnjU0jwlJ6cKsgq3ie8+PL6iRxgZm6RU56 2XPNQY3N5i8qB+03VpcXWUA= Received: (qmail 1179 invoked by alias); 1 Nov 2013 15:56:42 -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 1158 invoked by uid 89); 1 Nov 2013 15:56:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wg0-f41.google.com Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 01 Nov 2013 15:56:40 +0000 Received: by mail-wg0-f41.google.com with SMTP id b13so1189730wgh.0 for ; Fri, 01 Nov 2013 08:56:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.12.198 with SMTP id a6mr2733540wic.38.1383321397271; Fri, 01 Nov 2013 08:56:37 -0700 (PDT) Received: by 10.217.13.12 with HTTP; Fri, 1 Nov 2013 08:56:36 -0700 (PDT) Date: Fri, 1 Nov 2013 16:56:36 +0100 Message-ID: Subject: [Patch, fortran] PR57445 - [4.8/4.9 Regression] ICE in gfc_conv_class_to_class - for OPTIONAL polymorphic array From: Paul Richard Thomas To: "fortran@gcc.gnu.org" , gcc-patches Dear All, This one is trivial. The ICE was caused by an assert that turns out to be spurious and has been removed. Bootstrapped and regtested on FC17/x86_64 - OK for trunk and 4.8? Cheers Paul 2013-11-01 Paul Thomas PR fortran/57445 * trans-expr.c (gfc_conv_class_to_class): Remove spurious assert. 2013-11-01 Paul Thomas PR fortran/57445 * gfortran.dg/optional_class_1.f90 : New test Index: gcc/fortran/trans-expr.c =================================================================== *** gcc/fortran/trans-expr.c (revision 204285) --- gcc/fortran/trans-expr.c (working copy) *************** gfc_conv_class_to_class (gfc_se *parmse, *** 737,743 **** gfc_add_modify (&parmse->post, vptr, fold_convert (TREE_TYPE (vptr), ctree)); - gcc_assert (!optional || (optional && !copyback)); if (optional) { tree tmp2; --- 737,742 ---- *************** is_runtime_conformable (gfc_expr *expr1, *** 7769,7775 **** e1 = a->expr; if (e1->rank > 0 && !is_runtime_conformable (expr1, e1)) return false; ! } return true; } else if (expr2->value.function.isym --- 7768,7774 ---- e1 = a->expr; if (e1->rank > 0 && !is_runtime_conformable (expr1, e1)) return false; ! } return true; } else if (expr2->value.function.isym Index: gcc/testsuite/gfortran.dg/optional_class_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/optional_class_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/optional_class_1.f90 (working copy) *************** *** 0 **** --- 1,45 ---- + ! { dg-do run } + ! + ! PR fortran/57445 + ! + ! Contributed by Tobias Burnus + ! + ! Spurious assert was added at revision 192495 + ! + module m + implicit none + type t + integer :: i + end type t + contains + subroutine opt(xa, xc, xaa, xca) + type(t), allocatable, intent(out), optional :: xa + class(t), allocatable, intent(out), optional :: xc + type(t), allocatable, intent(out), optional :: xaa(:) + class(t), allocatable, intent(out), optional :: xca(:) + if (present (xca)) call foo_opt(xca=xca) + end subroutine opt + subroutine foo_opt(xa, xc, xaa, xca) + type(t), allocatable, intent(out), optional :: xa + class(t), allocatable, intent(out), optional :: xc + type(t), allocatable, intent(out), optional :: xaa(:) + class(t), allocatable, intent(out), optional :: xca(:) + if (present (xca)) then + if (allocated (xca)) deallocate (xca) + allocate (xca(3), source = [t(9),t(99),t(999)]) + end if + end subroutine foo_opt + end module m + use m + class(t), allocatable :: xca(:) + allocate (xca(1), source = t(42)) + select type (xca) + type is (t) + if (any (xca%i .ne. [42])) call abort + end select + call opt (xca = xca) + select type (xca) + type is (t) + if (any (xca%i .ne. [9,99,999])) call abort + end select + end