From patchwork Wed Jul 18 15:17:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 171718 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 7F3B52C0084 for ; Thu, 19 Jul 2012 01:18:08 +1000 (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=1343229489; 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=8Eexth4 BrInEV8DI6EH9hiQN51o=; b=KNoGrnN1P3pbUcCuPDZKpTEzUT8RfU0xsDdJzrP ZcHhBZAvkvHSsiZ9Iz1330YPSkUirfpMau8mo7L+U97NInLfILHyzZOAAtuwIeUE GqaKKij6CtYO2MRGPktJwoN3D/iUID9fCgbTEYO8ig/pBJMlROtDtKzOBq0K964w 9dNg= 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=kUWAvBeHcjDHC7MQTZEoM7tfzJ8VUVJBMPewtf4QkIdR2rEfbr1uGTqkpdESUH Cz3CHcQRGHtPcJ4U3xloL+LbUGwjXiUcBSlPL7EK7ZuHELKFGgKA7wAe8svvIlgV ZXm7KPkirg50PpekNZhOlsiu1NLKY6CWd9Qm3WSojj2p8=; Received: (qmail 24467 invoked by alias); 18 Jul 2012 15:18:02 -0000 Received: (qmail 24414 invoked by uid 22791); 18 Jul 2012 15:18:00 -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 mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Jul 2012 15:17:46 +0000 Received: from [192.168.178.22] (port-92-204-53-225.dynamic.qsc.de [92.204.53.225]) by mx01.qsc.de (Postfix) with ESMTP id D9C773CEAD; Wed, 18 Jul 2012 17:17:39 +0200 (CEST) Message-ID: <5006D391.5000102@net-b.de> Date: Wed, 18 Jul 2012 17:17:37 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] Allow assumed-shape arrays with BIND(C) for TS29113 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 This patch was written on top of the big assumed-shape patch.* However, it should also work by itself. Bootstrapped and regtested on x86-64-linux. OK for the trunk? Tobias * http://gcc.gnu.org/ml/fortran/2012-07/msg00052.html 2012-07-18 Tobias Burnus * decl.c (gfc_verify_c_interop_param): Allow assumed-shape with -std=f2008ts. 2012-07-18 Tobias Burnus * gfortran.dg/bind_c_array_params_2.f90: New. * gfortran.dg/bind_c_array_params.f03: Add -std=f2003 and update dg-error. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 01693ad..4184608 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1092,29 +1096,15 @@ gfc_verify_c_interop_param (gfc_symbol *sym) retval = FAILURE; /* Make sure that if it has the dimension attribute, that it is - either assumed size or explicit shape. */ - if (sym->as != NULL) - { - if (sym->as->type == AS_ASSUMED_SHAPE) - { - gfc_error ("Assumed-shape array '%s' at %L cannot be an " - "argument to the procedure '%s' at %L because " - "the procedure is BIND(C)", sym->name, - &(sym->declared_at), sym->ns->proc_name->name, - &(sym->ns->proc_name->declared_at)); - retval = FAILURE; - } - - if (sym->as->type == AS_DEFERRED) - { - gfc_error ("Deferred-shape array '%s' at %L cannot be an " - "argument to the procedure '%s' at %L because " - "the procedure is BIND(C)", sym->name, - &(sym->declared_at), sym->ns->proc_name->name, - &(sym->ns->proc_name->declared_at)); - retval = FAILURE; - } - } + either assumed size or explicit shape. Deferred shape is already + covered by the pointer/allocatable attribute. */ + if (sym->as != NULL && sym->as->type == AS_ASSUMED_SHAPE + && gfc_notify_std (GFC_STD_F2008_TS, "Assumed-shape array '%s' " + "at %L as dummy argument to the BIND(C) " + "procedure '%s' at %L", sym->name, + &(sym->declared_at), sym->ns->proc_name->name, + &(sym->ns->proc_name->declared_at)) == FAILURE) + retval = FAILURE; } } diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params.f03 b/gcc/testsuite/gfortran.dg/bind_c_array_params.f03 index 6590db1..810f642 100644 --- a/gcc/testsuite/gfortran.dg/bind_c_array_params.f03 +++ b/gcc/testsuite/gfortran.dg/bind_c_array_params.f03 @@ -1,10 +1,11 @@ ! { dg-do compile } +! { dg-options "-std=f2003" } module bind_c_array_params use, intrinsic :: iso_c_binding implicit none contains - subroutine sub0(assumed_array) bind(c) ! { dg-error "cannot be an argument" } + subroutine sub0(assumed_array) bind(c) ! { dg-error "TS 29113: Assumed-shape array 'assumed_array' at .1. as dummy argument to the BIND.C. procedure 'sub0'" } integer(c_int), dimension(:) :: assumed_array end subroutine sub0 --- /dev/null 2012-07-18 07:03:52.759757921 +0200 +++ gcc/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 2012-07-18 00:14:13.000000000 +0200 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-std=f2008ts -fdump-tree-original" } +! +! Check that assumed-shape variables are correctly passed to BIND(C) +! as defined in TS 29913 +! +interface + subroutine test (xx) bind(C, name="myBindC") + type(*), dimension(:,:) :: xx + end subroutine test +end interface + +integer :: aa(4,4) +call test(aa) +end + +! { dg-final { scan-tree-dump-times "test \\\(&parm\\." 1 "original" } } +! { dg-final { scan-assembler-times "myBindC" 1 } } +