From patchwork Mon Aug 12 22:32:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1145935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506740-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="smGMY/5P"; dkim-atps=neutral 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 466rFd5RPBz9s00 for ; Tue, 13 Aug 2019 08:32:35 +1000 (AEST) 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:reply-to:mime-version:content-type; q=dns; s=default; b=VbTVhn1BZssnxQw00ed9kjLkrP2rhpxNnHjv6onw9f2 awJAnO9dS/clz9AYUG407BMvO4zyfUf5GxTNjP86PlHXim9MyM08dxClpGNp3dcm Z6qCUhrxSI/xXQRDDMxk52BUZf4HgTKuGzsSPImGhn3cI0gVhijWfwVMaqIS4FrU = 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:reply-to:mime-version:content-type; s=default; bh=qpEOS5eIEK+I8Int5/VCRRXCV/s=; b=smGMY/5PNPSUW84KN Och2lbmMaly0mT9agvZdcCorB5OpuVxSWkO3rMPNJgUnotlSVHtF64IN7PHCFrrz u2k7tedQg1W3NdKR3Q6wBLpvVMEKd1OpSq2BCedvtJkrPxZdeDjpXbMtDmJVYoM/ xGQ+4uWv6Xli2TnPeC7uPwE4dQ= Received: (qmail 112577 invoked by alias); 12 Aug 2019 22:32:28 -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 112561 invoked by uid 89); 12 Aug 2019 22:32:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=H*MI:edu, PUBLIC, UD:resolve.c, resolve.c X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Aug 2019 22:32:26 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x7CMWOcf043891 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 12 Aug 2019 15:32:25 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x7CMWOjX043890; Mon, 12 Aug 2019 15:32:24 -0700 (PDT) (envelope-from sgk) Date: Mon, 12 Aug 2019 15:32:24 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/89647 -- Allow host associated procedure to be a binding target Message-ID: <20190812223224.GA43857@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) The attached patch fixes PR fortran/89647, and has been regression tested on x86_64-*-freebsd. If a procedure is made accessible by host association, the that procedure can be used as binding target. During the resolution of a type bound procedure, gfortran needs to check the parent namespace for a procedure before it fails. 2019-08-12 Steven G. Kargl PF fortran/89647 resolve.c (resolve_typebound_procedure): Allow host associated procedure to be a binding target. While here, wrap long line. 2019-08-12 Steven G. Kargl PF fortran/89647 * gfortran.dg/pr89647.f90: New test. OK to commit? Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 274320) +++ gcc/fortran/resolve.c (working copy) @@ -13583,14 +13583,34 @@ resolve_typebound_procedure (gfc_symtree* stree) } else { + /* If proc has not been resolved at this point, proc->name may + actually be a USE associated entity. See PR fortran/89647. */ + if (!proc->resolved + && proc->attr.function == 0 && proc->attr.subroutine == 0) + { + gfc_symbol *tmp; + gfc_find_symbol (proc->name, gfc_current_ns->parent, 1, &tmp); + if (tmp && tmp->attr.use_assoc) + { + proc->module = tmp->module; + proc->attr.proc = tmp->attr.proc; + proc->attr.function = tmp->attr.function; + proc->attr.subroutine = tmp->attr.subroutine; + proc->attr.use_assoc = tmp->attr.use_assoc; + proc->ts = tmp->ts; + proc->result = tmp->result; + } + } + /* Check for F08:C465. */ if ((!proc->attr.subroutine && !proc->attr.function) || (proc->attr.proc != PROC_MODULE && proc->attr.if_source != IFSRC_IFBODY) || proc->attr.abstract) { - gfc_error ("%qs must be a module procedure or an external procedure with" - " an explicit interface at %L", proc->name, &where); + gfc_error ("%qs must be a module procedure or an external " + "procedure with an explicit interface at %L", + proc->name, &where); goto error; } } Index: gcc/testsuite/gfortran.dg/pr89647.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr89647.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr89647.f90 (working copy) @@ -0,0 +1,33 @@ +! { dg-do compile } +! Code contributed by Ian Harvey + MODULE m1 + IMPLICIT NONE + PUBLIC :: False + PUBLIC :: True + CONTAINS + FUNCTION False() RESULT(b) + LOGICAL :: b + b = .FALSE. + END FUNCTION False + + FUNCTION True() RESULT(b) + LOGICAL :: b + b = .TRUE. + END FUNCTION True + END MODULE m1 + + MODULE m2 + USE m1 + IMPLICIT NONE + TYPE, ABSTRACT :: t_parent + CONTAINS + PROCEDURE(False), DEFERRED, NOPASS :: Binding + END TYPE t_parent + CONTAINS + SUBROUTINE s + TYPE, EXTENDS(t_parent) :: t_extension + CONTAINS + PROCEDURE, NOPASS :: Binding => True + END TYPE t_extension + END SUBROUTINE s + END MODULE m2