From patchwork Fri Mar 9 22:00:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 145767 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]) by ozlabs.org (Postfix) with SMTP id DC546B6ED0 for ; Sat, 10 Mar 2012 09:01:00 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331935262; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=VyEV9Fw dEOnCJoBwtzh9zMRGm4o=; b=PK18/rM5rZaRg3bkP+S0mq5pB5oT64npFnzN4f3 7mHTR+iCNUEahFuHeYo25z/JLC9tpV0EsgHP0r2oT1zjzesY9e2FsXgZQMWKOu0w HnI4bQiNDLQJSlizj/y/lGIr6qkO11WLR50/elZz7kBNur3KX/0PeKONtMmsMDIV JBSc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Wrc8/zBqZPF+Mo0f68+VKigNAFFr7n53ErPFsMaicJvMtBA5PCTeAzWQcgrr76 2VCEqLiMsywowwBWcD46MHfViUgPAB3muc7HirYYVWqcoSrbK1w/dLpJ1MM7H/kR ZTxgg4bLiP3rHwnPRpp/ZGO4PnOWRKBXn4qtdTD07VZzs=; Received: (qmail 23934 invoked by alias); 9 Mar 2012 22:00:54 -0000 Received: (qmail 23917 invoked by uid 22791); 9 Mar 2012 22:00:54 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Mar 2012 22:00:39 +0000 Received: from [192.168.178.22] (port-92-204-75-4.dynamic.qsc.de [92.204.75.4]) by mx02.qsc.de (Postfix) with ESMTP id 536ED1E10A; Fri, 9 Mar 2012 23:00:37 +0100 (CET) Message-ID: <4F5A7D83.9010203@net-b.de> Date: Fri, 09 Mar 2012 23:00:35 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C) 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 If the interface in a PROCEDURE() statement is Bind(C), also the procedure (pointer) declared in that statement is BIND(C). From the F2008 standard: "A proc-language-binding-spec without a NAME= is allowed, but is redundant with the proc-interface required by C1222." Build and currently regtested on x86-64-linux. OK for the trunk (if regtesting succeeded)? Tobias 2012-03-10 Tobias Burnus PR fortran/52542 * decl.c (match_procedure_decl): If the interface is bind(C), the procedure is as well. 2012-03-10 Tobias Burnus PR fortran/52542 * gfortran.dg/proc_ptr_35.f90: New. --- /dev/null 2012-03-09 19:41:57.079829322 +0100 +++ gcc/gcc/testsuite/gfortran.dg/proc_ptr_35.f90 2012-03-09 22:22:31.000000000 +0100 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR fortran/52542 +! +! Ensure that the procedure myproc is Bind(C). +! +! Contribute by Mat Cross of NAG +! +interface + subroutine s() bind(c) + end subroutine s +end interface +procedure(s) :: myproc +call myproc() +end +! { dg-final { scan-assembler-not "myproc_" } } diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 75b8a89..7c5e518 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4855,6 +4855,9 @@ match_procedure_decl (void) if (m == MATCH_ERROR) return MATCH_ERROR; + if (proc_if && proc_if->attr.is_bind_c) + current_attr.is_bind_c = 1; + /* Get procedure symbols. */ for(num=1;;num++) {