From patchwork Wed Jun 19 21:10:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1119011 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-503312-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="WfYaH0xf"; 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 45Td0Z6JGCz9s4Y for ; Thu, 20 Jun 2019 07:11:08 +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=DPLLo/XGSfTharIB8TlR9NlnDmGhUlWUQfz5WKkx30Z I4lY2RB0POxM25IFo+wHq3a78Gmn5HkEbfWCD3SFtlqjoKcZ/0Z7GdUxw3LLcMvX XT1Ihv8658tQTpy5oErJognupv7eghF/EqIKIvXrM2zkxEsnQ7OvtQLRZduZnDnM = 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=xqRUhMJoLL1t6xQACf/7Bm0LITs=; b=WfYaH0xf2k928mAnS fhpEotpnlA5vpQWtA4yhsOLy/xU3RvYie19PArNUp603KvAX8jpCSdeh3mZiej16 SsujMU/6to29NzOI//CnLpYeHIx5jR2/JRmRb2WmOG1u0aN7o1MpYm7eBlOKoF4F asso8ro/Gm9BvDRdpAAe78Ytzc= Received: (qmail 62993 invoked by alias); 19 Jun 2019 21:10:55 -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 62977 invoked by uid 89); 19 Jun 2019 21:10:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=gfc_symbol 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; Wed, 19 Jun 2019 21:10:54 +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 x5JLAqXP046069 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jun 2019 14:10:52 -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 x5JLAq2k046065; Wed, 19 Jun 2019 14:10:52 -0700 (PDT) (envelope-from sgk) Date: Wed, 19 Jun 2019 14:10:52 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/86587 -- PRIVATE and BIND(C) are allowed for derived type Message-ID: <20190619211052.GA99095@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) Revision 126185 introduced ISO C Binding to gfortran. In that revision, a check for a conflict between a derived type with the PRIVATE attribute and BIND(C) was introduced. After checking the F2003, F2008, and F2018 standards, I cannot find this restriction. Thus, the check is removed by the attached patch. Regression checked on x86_64-*-freebsd. OK to commit? 2019-06-19 Steven G. Kargl PR fortran/86587 * symbol.c (verify_bind_c_derived_type): Remove erroneous error checking for BIND(C) and PRIVATE attributes. 2019-06-19 Steven G. Kargl PR fortran/86587 * gfortran.dg/pr86587.f90: New test. Index: gcc/fortran/symbol.c =================================================================== --- gcc/fortran/symbol.c (revision 272481) +++ gcc/fortran/symbol.c (working copy) @@ -4529,16 +4529,6 @@ verify_bind_c_derived_type (gfc_symbol *derived_sym) curr_comp = curr_comp->next; } while (curr_comp != NULL); - - /* Make sure we don't have conflicts with the attributes. */ - if (derived_sym->attr.access == ACCESS_PRIVATE) - { - gfc_error ("Derived type %qs at %L cannot be declared with both " - "PRIVATE and BIND(C) attributes", derived_sym->name, - &(derived_sym->declared_at)); - retval = false; - } - if (derived_sym->attr.sequence != 0) { gfc_error ("Derived type %qs at %L cannot have the SEQUENCE " Index: gcc/testsuite/gfortran.dg/pr86587.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr86587.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr86587.f90 (working copy) @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/86587 +! Code contirubted by Valentin Clement +! +module mod1 + use iso_c_binding + type, bind(c), private :: mytype + integer(c_int) :: i1, i2 + end type +end module mod1 + +module mod2 + use iso_c_binding + private + type, bind(c) :: mytype + integer(c_int) :: i1, i2 + end type +end module mod2