public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: gcc patches <gcc-patches@gcc.gnu.org>, gfortran <fortran@gcc.gnu.org>
Subject: Re: [Patch, Fortran] -std=f2008tr, TR 29113 and OPTIONAL arguments with BIND(C)
Date: Thu, 05 May 2011 20:18:00 -0000	[thread overview]
Message-ID: <4DC305E5.1090804@net-b.de> (raw)
In-Reply-To: <4DC23986.6080904@net-b.de>

[-- Attachment #1: Type: text/plain, Size: 129 bytes --]


> Build and regtested on x86-64-linux
> OK for the trunk?

I forgot to include a run-time test case. Find one attached.

Tobias

[-- Attachment #2: bind_c_usage_24.f90 --]
[-- Type: text/plain, Size: 968 bytes --]

! { 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" } }

[-- Attachment #3: bind_c_usage_24_c.c --]
[-- Type: text/x-csrc, Size: 376 bytes --]

/* Compiled and linked by bind_c.f90.  */

#include <stdlib.h>

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 ();
}

  reply	other threads:[~2011-05-05 20:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05  6:08 Tobias Burnus
2011-05-05 20:18 ` Tobias Burnus [this message]
2011-05-06 16:22 ` Jerry DeLisle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC305E5.1090804@net-b.de \
    --to=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).