From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10172 invoked by alias); 5 May 2011 20:18:01 -0000 Received: (qmail 10151 invoked by uid 22791); 5 May 2011 20:17:59 -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; Thu, 05 May 2011 20:17:43 +0000 Received: from [192.168.178.22] (port-92-204-45-85.dynamic.qsc.de [92.204.45.85]) by mx02.qsc.de (Postfix) with ESMTP id 7F9971E4DB; Thu, 5 May 2011 22:17:41 +0200 (CEST) Message-ID: <4DC305E5.1090804@net-b.de> Date: Thu, 05 May 2011 20:18:00 -0000 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: gcc patches , gfortran Subject: Re: [Patch, Fortran] -std=f2008tr, TR 29113 and OPTIONAL arguments with BIND(C) References: <4DC23986.6080904@net-b.de> In-Reply-To: <4DC23986.6080904@net-b.de> Content-Type: multipart/mixed; boundary="------------040804050006090703070503" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00462.txt.bz2 This is a multi-part message in MIME format. --------------040804050006090703070503 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 129 > Build and regtested on x86-64-linux > OK for the trunk? I forgot to include a run-time test case. Find one attached. Tobias --------------040804050006090703070503 Content-Type: text/plain; name="bind_c_usage_24.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bind_c_usage_24.f90" Content-length: 968 ! { dg-do run } ! { dg-additional-sources bind_c_usage_24_c.c } ! ! PR fortran/48858 ! PR fortran/48820 ! ! TR 29113: BIND(C) with OPTIONAL ! module m use iso_c_binding interface subroutine c_proc (is_present, var) bind(C) import logical(c_bool), value :: is_present integer(c_int), optional :: var end subroutine end interface contains subroutine subtest (is_present, var) bind(C) logical(c_bool), intent(in), value :: is_present integer(c_int), intent(inout), optional :: var if (is_present) then if (.not. present (var)) call abort () if (var /= 43) call abort () var = -45 else if (present (var)) call abort () end if end subroutine subtest end module m program test use m implicit none integer :: val val = 4 call c_proc (.false._c_bool) call c_proc (.true._c_bool, val) if (val /= 7) call abort () end program test ! { dg-final { cleanup-modules "m" } } --------------040804050006090703070503 Content-Type: text/x-csrc; name="bind_c_usage_24_c.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bind_c_usage_24_c.c" Content-length: 376 /* Compiled and linked by bind_c.f90. */ #include void subtest (_Bool, int *); void c_proc (_Bool present, int *val) { int val2; if (!present && val) abort (); else if (present) { if (!val) abort (); if (*val != 4) abort (); *val = 7; } val2 = 43; subtest (1, &val2); subtest (0, NULL); if (val2 != -45) abort (); } --------------040804050006090703070503--