From patchwork Thu Dec 8 12:56:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 704058 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 3tZFkP4Pkjz9t3N for ; Thu, 8 Dec 2016 23:57:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZvrmGf87"; 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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=qHIyCCSZWpd8mmJ9sEdJF809q35ZERhRCENO5tQEfxVCM8 g21FRQP8J5DfxVwB1Yx5GHAMxCYUECuLUI6yB7sbGsolj6SfNLJTp5jDaz6ctlvk 6xSjow9BhWR0tSj3l0sp2ZTWCkjZF0iIMFmyYX3JgMadiNVaCLzwMZfWxroxk= 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:from:date:message-id:subject:to:content-type; s= default; bh=v8f2GOYipL9miO/rPWwUSicO0kk=; b=ZvrmGf87nCm1u1PszBAg L54p1ZLivtiVJU4dn/fA9R/VbXdMsIpe6WqKikRg00NPQkixaI17FFR+67SeAuqw 7lgHztk5JCNLIsaecymaby05xKg2f5UX2FNyiv3jJVOWOWruGjIONgNaiv2WYCQt NdZ73+5C9lFjpYznDtBaMJo= Received: (qmail 91454 invoked by alias); 8 Dec 2016 12:56:43 -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 90513 invoked by uid 89); 8 Dec 2016 12:56:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=communicator X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yw0-f196.google.com Received: from mail-yw0-f196.google.com (HELO mail-yw0-f196.google.com) (209.85.161.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Dec 2016 12:56:32 +0000 Received: by mail-yw0-f196.google.com with SMTP id r204so34501175ywb.3; Thu, 08 Dec 2016 04:56:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=pwGLVY6pJnx1tCsIo4NcWV+Bpp3O7IYSyFM9DL25lII=; b=mtITV0OcWFWOpi3aK3bmWeBMkhZ08NwnBZ0Fsyx7b+z8AKtLijkNkyQpmAD/5StPWL gYK0yYg2q3xZQKkhWxeqO0sfN9GCIb4o/38K/d+C3wLfK1Mvu9twfkubQmRbFcDSGQEz U0eJwQtaxkU9dvzwoHvUvY/S5QkC57n4rPPWsKr/p0evPp4oP9OS9HCZL/6GfDCk6KeB EepJ/tgJm8UIq7tqAx/Eb9110LL4ah/sQ5ICr4nGbOYIwg7d4pwmBUi/g2fYyreI5OnB QyrJ/GGommXDe17R4QIE3nu/kKXOFaf3ce4faalIT2c/5yyA2dZ8vAXu1gwx4Z8qqdDc jOKA== X-Gm-Message-State: AKaTC02SgY3Rb8O9gkyHRkzQjSE6Xx1mf+ps02HexPucl7Oqs/UoVfnsYz1zkKaSTJYmOQ7nO1TqR35yriWjJA== X-Received: by 10.37.160.41 with SMTP id x38mr40936662ybh.64.1481201789650; Thu, 08 Dec 2016 04:56:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.51.145 with HTTP; Thu, 8 Dec 2016 04:56:29 -0800 (PST) From: Janus Weil Date: Thu, 8 Dec 2016 13:56:29 +0100 Message-ID: Subject: [Patch, Fortran, OOP] PR 61767: ICE in generate_finalization_wrapper at fortran/class.c:1491 To: gfortran , gcc-patches Hi all, the attached patch fixes an ice-on-valid problem with finalization. The ICE turned out to be caused by a bug in 'has_finalizer_component': According to the documentation, this function is supposed to detect whether a derived type has any nonpointer nonallocatable components that have a finalizer. However it triggered also on pointer components with a finalizer. Fixing this makes the ICE go away. The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk? Cheers, Janus 2016-12-08 Janus Weil PR fortran/61767 * class.c (has_finalizer_component): Fix this function to detect only non-pointer non-allocatable components which have a finalizer. 2016-12-08 Janus Weil PR fortran/61767 * gfortran.dg/finalize_31.f90: New test. Index: gcc/fortran/class.c =================================================================== --- gcc/fortran/class.c (revision 243433) +++ gcc/fortran/class.c (working copy) @@ -841,20 +841,19 @@ has_finalizer_component (gfc_symbol *derived) gfc_component *c; for (c = derived->components; c; c = c->next) - { - if (c->ts.type == BT_DERIVED && c->ts.u.derived->f2k_derived - && c->ts.u.derived->f2k_derived->finalizers) - return true; + if (c->ts.type == BT_DERIVED && !c->attr.pointer && !c->attr.allocatable) + { + if (c->ts.u.derived->f2k_derived + && c->ts.u.derived->f2k_derived->finalizers) + return true; - /* Stop infinite recursion through this function by inhibiting - calls when the derived type and that of the component are - the same. */ - if (c->ts.type == BT_DERIVED - && !gfc_compare_derived_types (derived, c->ts.u.derived) - && !c->attr.pointer && !c->attr.allocatable - && has_finalizer_component (c->ts.u.derived)) - return true; - } + /* Stop infinite recursion through this function by inhibiting + calls when the derived type and that of the component are + the same. */ + if (!gfc_compare_derived_types (derived, c->ts.u.derived) + && has_finalizer_component (c->ts.u.derived)) + return true; + } return false; }