From patchwork Thu Jul 14 14:56:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 648427 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 3rqzLB4sPsz9sDk for ; Fri, 15 Jul 2016 00:56:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=u3vvqVHd; 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=RxdC75cSmPEc9m1jbmcQkEGXOXMwNufnEejLPhipAqJW5F6fEt+so 6a3QOHjzbTGypkD6KehUNUUuxP85vfXDkiktEWRUBvPEOKi1Xb6XVc6GinxdUARx t+P8FTGVVcjRZEE6EMdeBxgcgP3pFlU/ZiUSv3sbi+Xc0rk+9dx+Xc= 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:subject:message-id:mime-version:content-type; s= default; bh=UbehzU0KyCm5VmVLKvHV+oKe+mA=; b=u3vvqVHdpZE0sISsBZbk pDhE6sUwq88Wh4O7PY58IFoQ4pbgyezC59dGt97q0Rzy2vb1fx84wpTi2PXHvN9n Ru2COAgcmbZDDu+hdA/i0OAg8wjNROdnP8JjVx+kaT6DnLoEYviuiNL7LDPP2cLb 2KD7GWVGxHObA2n0pIV0P4Y= Received: (qmail 98654 invoked by alias); 14 Jul 2016 14:56:25 -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 98629 invoked by uid 89); 14 Jul 2016 14:56:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=nathanael, Nathanael, assoc, online 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 ESMTP; Thu, 14 Jul 2016 14:56:14 +0000 Received: from vepi2 ([92.209.45.60]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LmJsk-1anpLB3jn8-00ZwJV; Thu, 14 Jul 2016 16:56:08 +0200 Date: Thu, 14 Jul 2016 16:56:07 +0200 From: Andre Vehreschild To: GCC-Patches-ML , GCC-Fortran-ML Subject: [Fortran, Patch, PR70842, v1] [4.9/5/6/7 Regression] internal compiler error with character members within a polymorphic pointer Message-ID: <20160714165607.54c9a364@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:PPLU42p2rVA=:ISjP1lH9KBq4TBehxq+U7+ 2yf0/XmKRu82mI1E2hf1SKeEBi7kaYXtA1DT4qhUIEwqYXhUL3drUEuEi8w+n/hPLXuRNjQkL 7F8Kd2LEmD4VvoeZgl5FrePORw/4qugnSExhsqyY3d8hXJzFRZ6xuJtcsx/XhhEYaNfH3k+Ii FyDYd6vpkep75EjNrrJXJ2s4X+77S1kKzyOb54b/gKOAC5z6k8kGP8o98temCyHY+XOzH5QiG +RMmZyCL6gzMUv9qx/ddSFiUQXKuVmTMdeAHByJvT8YYulZ0w3kVHWh5gj03lunpdidaQ39mQ Yj6Vkf/tj3p/mlUd9mf9iSqXEyrBw91iMW6M4MYn+Tr6K/1jLtI6Rv72eVT0LP6IimCmTiGfG O7o5Cd16/Rw+nIDEKqJ/Lr+scln2j3cHKbeNq+dQHeYXS1doiZfzKxcuf5RQ2aMSP/I7v69Jh A1b16KrJBRTybhlsIx+cJtMiBmvgHxvSt3rhQUGGw/WYfFfw7zPf4OpfZ1qiHCzQJtyfDW04P qYdlEmeNMTc9aoOotqADa47zkwHctuGd/erYB1brb0KMJdJ4a7G1DTJT0U0QK5o+VpPcCw1+E KN2iG91x/wu/rZFm+ICJKO8vtnrI8VMxD5Y2MkTLm1dtIqA0+6Bm5CaW4Zsb0wgEDiQWut9nD OBSstpy8ApodhQUdxSi/lr+MqjR3l0en9xpE+Udu+jvpo45lN4kjadgQt0C0aSA7okFaloU1/ civkSOQ67n2+7pBzwctTPocYRX2ykP15FMpqOHGP6HW5D9u4sGgA68l5pUE= Hi all, attached patch fixes the ICE and the wrong char array length mentioned in comment #3 of the PR. The issue was that getting the _len component is valid online for unlimited polymorphic pointers. But here this was tried for polymorphic entity, which had to fail. Bootstrapped and regtests ok on trunk, gcc-6-branch, gcc-5-branch, gcc-4_9-branch. Ok for trunk and one week later for the other branches? Regards, Andre diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 95a8d10..e3f4d50 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3816,8 +3816,11 @@ gfc_simplify_len (gfc_expr *e, gfc_expr *kind) } else if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_CHARACTER && e->symtree->n.sym + && e->symtree->n.sym->ts.type != BT_DERIVED && e->symtree->n.sym->assoc && e->symtree->n.sym->assoc->target - && e->symtree->n.sym->assoc->target->ts.type == BT_DERIVED) + && e->symtree->n.sym->assoc->target->ts.type == BT_DERIVED + && e->symtree->n.sym->assoc->target->symtree->n.sym + && UNLIMITED_POLY (e->symtree->n.sym->assoc->target->symtree->n.sym)) /* The expression in assoc->target points to a ref to the _data component of the unlimited polymorphic entity. To get the _len component the last _data ref needs to be stripped and a ref to the _len component added. */ diff --git a/gcc/testsuite/gfortran.dg/select_type_35.f03 b/gcc/testsuite/gfortran.dg/select_type_35.f03 new file mode 100644 index 0000000..92d2f27 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_35.f03 @@ -0,0 +1,41 @@ +! { dg-do run } +! +! Contributed by Nathanael Huebbe +! Check fix for PR/70842 + +program foo + + TYPE, ABSTRACT :: t_Intermediate + END TYPE t_Intermediate + + type, extends(t_Intermediate) :: t_Foo + character(:), allocatable :: string + end type t_Foo + + class(t_Foo), allocatable :: obj + + allocate(obj) + obj%string = "blabarfoo" + + call bar(obj) + + deallocate(obj) +contains + subroutine bar(me) + class(t_Intermediate), target :: me + + class(*), pointer :: alias + + select type(me) + type is(t_Foo) + if (len(me%string) /= 9) call abort() + end select + + alias => me + select type(alias) + type is(t_Foo) + if (len(alias%string) /= 9) call abort() + end select + end subroutine bar +end program foo +