From patchwork Mon Dec 15 19:59:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 421669 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 B191814009B for ; Tue, 16 Dec 2014 06:59:13 +1100 (AEDT) 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=bsPEWERjOR4XNVm76wXrPpRBV/qLE60FHgDybCzKrVQrV9 WBm1k72l226nAp/WHJ6BQPb+brTpmBJoeptONlFVPMXnW7UzzTItPaUwM7xr0cIp Y1C1yjZpDNqfsOUwm7wbnh8t1+nL4BDABAzBf0cbe75PgvdfvnY7aBffgH5uo= 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=MfgWL8vF7FElTTomeylMxLMYbsI=; b=hb/QL9SGoMMC81pqkSlW 2M5xt5Eyqehu4q/Nd37V1r/5Po1a+8XmTfNwCSIMP9YlX95SmjI1uGzyxGl4kY3D n73E+ONES7oGWFW2A0ogoUVd5/35PNNTQy2fYQUaKLy7FLwDusm1OZSWwlpA2rQZ 8MBUmLnnqAmAzH2nlpvmpa8= Received: (qmail 12709 invoked by alias); 15 Dec 2014 19:59:06 -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 12680 invoked by uid 89); 15 Dec 2014 19:59:04 -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_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-qg0-f48.google.com Received: from mail-qg0-f48.google.com (HELO mail-qg0-f48.google.com) (209.85.192.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 15 Dec 2014 19:59:03 +0000 Received: by mail-qg0-f48.google.com with SMTP id f51so9147280qge.35 for ; Mon, 15 Dec 2014 11:59:01 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.140.101.112 with SMTP id t103mr55866515qge.92.1418673540979; Mon, 15 Dec 2014 11:59:00 -0800 (PST) Received: by 10.96.54.194 with HTTP; Mon, 15 Dec 2014 11:59:00 -0800 (PST) Date: Mon, 15 Dec 2014 20:59:00 +0100 Message-ID: Subject: [Patch, Fortran, OOP] PR 64244: [4.8/4.9/5 Regression] ICE at class.c:236 when using non_overridable From: Janus Weil To: gfortran , gcc-patches Hi all, here is a regression fix for a problem with the NON_OVERRIDABLE attribute. For non-overridable type-bound procedures we do not have to generate a call to the vtable, but can just translate it to a simple ('non-virtual') function call. In this particular case, an additional generic binding was present, which fooled the compiler to believe that the call goes to an overridable procedure, so it tried to generate a call to a vtable entry which did not exist. The trick is simply to take the NON-OVERRIDABLE attribute from the specific procedure, not the generic one (which means the generic call has to be resolved to a specific one first). The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk? And for 4.8/4.9 after some time? Cheers, Janus 2014-12-15 Janus Weil PR fortran/64244 * resolve.c (resolve_typebound_call): New argument to pass out the non-overridable attribute of the specific procedure. (resolve_typebound_subroutine): Get overridable flag from resolve_typebound_call. 2014-12-15 Janus Weil PR fortran/64244 * gfortran.dg/typebound_call_26.f90: New. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (Revision 218751) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -5676,7 +5676,7 @@ success: /* Resolve a call to a type-bound subroutine. */ static bool -resolve_typebound_call (gfc_code* c, const char **name) +resolve_typebound_call (gfc_code* c, const char **name, bool *overridable) { gfc_actual_arglist* newactual; gfc_symtree* target; @@ -5700,6 +5700,10 @@ static bool if (!resolve_typebound_generic_call (c->expr1, name)) return false; + /* Pass along the NON_OVERRIDABLE attribute of the specific TBP. */ + if (overridable) + *overridable = !c->expr1->value.compcall.tbp->non_overridable; + /* Transform into an ordinary EXEC_CALL for now. */ if (!resolve_typebound_static (c->expr1, &target, &newactual)) @@ -5959,7 +5963,7 @@ resolve_typebound_subroutine (gfc_code *code) if (c->ts.u.derived == NULL) c->ts.u.derived = gfc_find_derived_vtab (declared); - if (!resolve_typebound_call (code, &name)) + if (!resolve_typebound_call (code, &name, NULL)) return false; /* Use the generic name if it is there. */ @@ -5991,7 +5995,7 @@ resolve_typebound_subroutine (gfc_code *code) } if (st == NULL) - return resolve_typebound_call (code, NULL); + return resolve_typebound_call (code, NULL, NULL); if (!resolve_ref (code->expr1)) return false; @@ -6004,10 +6008,10 @@ resolve_typebound_subroutine (gfc_code *code) || (!class_ref && st->n.sym->ts.type != BT_CLASS)) { gfc_free_ref_list (new_ref); - return resolve_typebound_call (code, NULL); + return resolve_typebound_call (code, NULL, NULL); } - if (!resolve_typebound_call (code, &name)) + if (!resolve_typebound_call (code, &name, &overridable)) { gfc_free_ref_list (new_ref); return false;