From patchwork Sun Aug 15 09:34:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 61751 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 0FB65B6EEF for ; Mon, 16 Aug 2010 02:14:28 +1000 (EST) Received: (qmail 18757 invoked by alias); 15 Aug 2010 16:14:26 -0000 Received: (qmail 18744 invoked by uid 22791); 15 Aug 2010 16:14:25 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_50 X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 15 Aug 2010 16:14:21 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OkZeD-00057G-Ft for gcc-patches@gcc.gnu.org; Sun, 15 Aug 2010 05:37:01 -0400 Received: from mx01.qsc.de ([213.148.129.14]:50791) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OkZeD-0004yw-Aj for gcc-patches@gcc.gnu.org; Sun, 15 Aug 2010 05:36:57 -0400 Received: from [192.168.178.22] (port-92-204-42-5.dynamic.qsc.de [92.204.42.5]) by mx01.qsc.de (Postfix) with ESMTP id ABA383D74E; Sun, 15 Aug 2010 11:34:50 +0200 (CEST) Message-ID: <4C67B4BA.9000003@net-b.de> Date: Sun, 15 Aug 2010 11:34:50 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.7) Gecko/20100714 SUSE/3.1.1 Thunderbird/3.1.1 MIME-Version: 1.0 To: gcc patches , gfortran , Daniel Kraft Subject: [Patch, Fortran] PR45211 - Fix DT BIND(C) check X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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 Derived types with BIND(C) are interoperable, but the check failed for derived types defined in a module procedure. The reason is that verify_c_interop checks for ts->u.derived->ts.is_c_interop which is only set after calling verify_bind_c_derived_type. However, verify_bind_c_derived_type is called in resolve.c - which is too late for the call to verify_c_interop. Build and regtested on x86-84-linux. OK for the trunk? Tobias 2010-08-15 Tobias Burnus PR fortran/45211 * decl.c (verify_c_interop_param): Remove superfluous space (" "). (verify_c_interop): Handle unresolved DT with bind(C). 2010-08-15 Tobias Burnus PR fortran/45211 * gfortran.dg/bind_c_usage_21.f90: New. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (Revision 163252) +++ gcc/fortran/decl.c (Arbeitskopie) @@ -991,7 +991,7 @@ verify_c_interop_param (gfc_symbol *sym) /* Make personalized messages to give better feedback. */ if (sym->ts.type == BT_DERIVED) gfc_error ("Type '%s' at %L is a parameter to the BIND(C) " - " procedure '%s' but is not C interoperable " + "procedure '%s' but is not C interoperable " "because derived type '%s' is not C interoperable", sym->name, &(sym->declared_at), sym->ns->proc_name->name, @@ -3612,7 +3612,8 @@ gfc_try verify_c_interop (gfc_typespec *ts) { if (ts->type == BT_DERIVED && ts->u.derived != NULL) - return (ts->u.derived->ts.is_c_interop ? SUCCESS : FAILURE); + return (ts->u.derived->ts.is_c_interop || ts->u.derived->attr.is_bind_c) + ? SUCCESS : FAILURE; else if (ts->is_c_interop != 1) return FAILURE; Index: gcc/testsuite/gfortran.dg/bind_c_usage_21.f90 =================================================================== --- gcc/testsuite/gfortran.dg/bind_c_usage_21.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/bind_c_usage_21.f90 (Revision 0) @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR fortran/45211 +! +! Contributed by Scot Breitenfeld +! +module m +contains + FUNCTION liter_cb(link_info) bind(C) + USE ISO_C_BINDING + IMPLICIT NONE + + INTEGER(c_int) liter_cb + + TYPE, bind(C) :: info_t + INTEGER(c_int) :: type + END TYPE info_t + + TYPE(info_t) :: link_info + + liter_cb = 0 + END FUNCTION liter_cb +end module m + +! { dg-final { cleanup-modules "m" } }