From patchwork Mon May 8 21:16:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 759798 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 3wMFgk6fGcz9s4s for ; Tue, 9 May 2017 07:17:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wdWO67qe"; 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=sbb81q9BuB7Kpc/n1NHGnaB9vLYquUpFM1k0ULDf5ijLaB AMkBNu9nufTEP3EobK7IfQ4H7UNcdIvieoTwtd0UN75YFf7DrVcCftuwKSyQ4BCp 69qCPDCbRxBPDFAwsXGrqmRaJAmlNtXN4zxSPLWUTBfgkpvYh23JucFcEWEDU= 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=nZydp8HpPAEWNxsPxiwIeBJuJc0=; b=wdWO67qeiywEQ9LViLum o5c013poemZSrzjcKld+8moO/X+hBgLTETcvCyDsC7pAcQ/WxcyoLIm/6DLZWaYr 1JMlreM0RwVG2sMDb9GPEEzDKNRopM730+oiES5CZXRKUmV/5ZQid5pihbRHdEzP LVLc5Bm2goAR9ylpELg36Po= Received: (qmail 109608 invoked by alias); 8 May 2017 21:16:50 -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 109584 invoked by uid 89); 8 May 2017 21:16:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=weil X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yb0-f175.google.com Received: from mail-yb0-f175.google.com (HELO mail-yb0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 May 2017 21:16:48 +0000 Received: by mail-yb0-f175.google.com with SMTP id 8so14866316ybw.1; Mon, 08 May 2017 14:16:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=MFUm3QtYWU1N446WQNKk/jwZqwA7zU9hBYLIP6Oi1N8=; b=fZVKqzm2FHl8+DRU8b5XzGm2nM9mXqSVOwomDErRNGzj9waVWb5U/Z6VVPDhltXBrz oHdNZlVJtosRYXdvo8MAl8sPolJKS4wKtRNCTt8jUsv3Fav9chZm8kAlDl+ZtbsvuRKx FPeeYkFqeBiAonOeysB1KyYr8i5vVkHxlpv3gLwQx1Tz7TyRDlAmpCA7SGTRWfLS92OQ B4RRJwjFjHSablJm9+zX6h8qW/1BBvSURt9tukm4jcKLn9X1aFKdL1HCUVfuT+ux7swl lUvSrGhPViRRlZnoFb2mkMGtYBQBfgvvxDsLVOBAQl4wBu00K0vN1Q1As/udZeXlEGHR 5h6A== X-Gm-Message-State: AODbwcB8gOnNwExyuJCUhyVE+NhlvbwTG4cT5HJtaEzDlUH+7Evp+/hh eP62v/FcdvDKQF+G939VuvnnWPfz8cH7 X-Received: by 10.37.111.139 with SMTP id k133mr11564142ybc.124.1494278208824; Mon, 08 May 2017 14:16:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.76.65 with HTTP; Mon, 8 May 2017 14:16:48 -0700 (PDT) From: Janus Weil Date: Mon, 8 May 2017 23:16:48 +0200 Message-ID: Subject: [Patch, Fortran, OOP] PR 79311: ICE in generate_finalization_wrapper, at fortran/class.c:1992 To: gfortran , gcc-patches Hi all, the attached patch fixes an ICE-on-valid problem with finalization by making sure that the finalization procedures are properly resolved. In the test case, the finalizer of the component type was not being resolved if the superordinate type had a finalizer itself. The patch also fixes a small error that had no actual impact on the test case ('has_final2' could never become true). Regtesting went well, except for these three failure which also seems to occur on a clean trunk currently: FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original FAIL: gfortran.dg/mvbits_7.f90 -O0 (test for warnings, line 28) Ok for trunk? Cheers, Janus 2017-05-08 Janus Weil PR fortran/79311 * resolve.c (gfc_resolve_finalizers): Ensure that derived-type components have a their finalizers resolved, also if the superordinate type itself has a finalizer. 2017-05-08 Janus Weil PR fortran/79311 * gfortran.dg/finalize_32.f90: New test. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 247757) +++ gcc/fortran/resolve.c (working copy) @@ -12385,26 +12385,23 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool if (parent) gfc_resolve_finalizers (parent, finalizable); - /* Return early when not finalizable. Additionally, ensure that derived-type - components have a their finalizables resolved. */ - if (!derived->f2k_derived || !derived->f2k_derived->finalizers) + /* Ensure that derived-type components have a their finalizers resolved. */ + bool has_final = derived->f2k_derived && derived->f2k_derived->finalizers; + for (c = derived->components; c; c = c->next) + if (c->ts.type == BT_DERIVED + && !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable) + { + bool has_final2 = false; + if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final2)) + return false; /* Error. */ + has_final = has_final || has_final2; + } + /* Return early if not finalizable. */ + if (!has_final) { - bool has_final = false; - for (c = derived->components; c; c = c->next) - if (c->ts.type == BT_DERIVED - && !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable) - { - bool has_final2 = false; - if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final)) - return false; /* Error. */ - has_final = has_final || has_final2; - } - if (!has_final) - { - if (finalizable) - *finalizable = false; - return true; - } + if (finalizable) + *finalizable = false; + return true; } /* Walk over the list of finalizer-procedures, check them, and if any one