From patchwork Sun Sep 9 16:31:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 967778 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-485366-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vLTs4lg1"; 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 427cBq5n3Lz9s2P for ; Mon, 10 Sep 2018 02:31:46 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=TEWLOjzvjuP/A5osB4NpZgvC8d1KfzpeYmj74HB855Bln6 81r2uH+sAssrDmTBRjXQ4a2Mm0v+0al1KI526q0iMeaFu23uiNfCmMdrQrEX68nJ liyyqydB/CGq2VbX75kLFbmfRAGcXjTd0mIs7BgHJ+IrOjUeHlXYzOn/u1yfA= 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=oDeQK7hHMhqRvKoF/yM1E8OontQ=; b=vLTs4lg1ULHXNKp4ZXxY 8vTZAiXBkgzjxO7kT3eqSBWFLoON2TvdbQkFfZ2fwMLQGIMGMop5Yt4xSihMDvxe LHkKl2Z4NLDCPP/i8I+kbaVcXzzwtfWvdfmftEn461yHttw9Io+X3BoL7Xpl9fja /6WdmLR6bJIs9bsXEmshcPQ= Received: (qmail 47832 invoked by alias); 9 Sep 2018 16:31:37 -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 47812 invoked by uid 89); 9 Sep 2018 16:31:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=contributed X-HELO: mail-yw1-f41.google.com Received: from mail-yw1-f41.google.com (HELO mail-yw1-f41.google.com) (209.85.161.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 09 Sep 2018 16:31:35 +0000 Received: by mail-yw1-f41.google.com with SMTP id m62-v6so7039635ywd.6; Sun, 09 Sep 2018 09:31:34 -0700 (PDT) MIME-Version: 1.0 From: Janus Weil Date: Sun, 9 Sep 2018 18:31:21 +0200 Message-ID: Subject: [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope To: gfortran , gcc-patches Hi all, the attached patch fixes a problem with the accessibility of procedure pointer components (private/public attribute). It is rather straightforward and regtest cleanly on x86_64-linux-gnu (for further details see the PR). Ok for trunk? Cheers, Janus diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7cfb94ee115..11adc5d13d5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-09-09 Janus Weil + + PR fortran/85395 + * decl.c (match_binding_attributes): Use correct default accessibility + for procedure pointer components. + 2018-09-03 Jerry DeLisle * simplify.c (gfc_simplify_modulo): Re-arrange code to test whether diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 03298833c98..3d19ad479e5 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -10570,7 +10570,8 @@ match_binding_attributes (gfc_typebound_proc* ba, bool generic, bool ppc) done: if (ba->access == ACCESS_UNKNOWN) - ba->access = gfc_typebound_default_access; + ba->access = ppc ? gfc_current_block()->component_access + : gfc_typebound_default_access; if (ppc && !seen_ptr) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c038441a8c..118c03f17f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-09 Janus Weil + + PR fortran/85395 + * gfortran.dg/proc_ptr_comp_52.f90: New test case. + 2018-09-08 Marek Polacek PR c++/87150 - wrong ctor with maybe-rvalue semantics. diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 new file mode 100644 index 00000000000..631c0180753 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! +! PR 85395: [F03] private clause contained in derived type acquires spurious scope +! +! Contributed by + +module defs + implicit none + + type :: base + contains + private + end type + + type :: options + procedure(), pointer, nopass :: ptr + end type + + type :: t + private + procedure(), pointer, nopass, public :: ptr + end type +end module + + +program p + use defs + implicit none + type(options) :: self + type(t) :: dt + self%ptr => null() + dt%ptr => null() +end