public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C)
@ 2012-03-09 22:00 Tobias Burnus
  2012-03-10 15:53 ` Tobias Burnus
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2012-03-09 22:00 UTC (permalink / raw)
  To: gcc patches, gfortran

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

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

[-- Attachment #2: procptr-bind_c.diff --]
[-- Type: text/x-patch, Size: 1084 bytes --]

2012-03-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52542
	* decl.c (match_procedure_decl): If the interface
	is bind(C), the procedure is as well.

2012-03-10  Tobias Burnus  <burnus@net-b.de>

	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++)
     {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C)
  2012-03-09 22:00 [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C) Tobias Burnus
@ 2012-03-10 15:53 ` Tobias Burnus
  2012-03-12  8:42   ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2012-03-10 15:53 UTC (permalink / raw)
  To: gcc patches, gfortran

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

Tobias Burnus wrote:
> 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)?

Well, it didn't as I forgot to reset two variables - one then gets then 
an error that one has specified an binding name - or the wrong binding 
name might be used.

Build and regtested on x86-64-linux.
OK?

Tobias

[-- Attachment #2: procptr-bind_c.diff --]
[-- Type: text/x-patch, Size: 1190 bytes --]

2012-03-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52542
	* decl.c (match_procedure_decl): If the interface
	is bind(C), the procedure is as well.

2012-03-10  Tobias Burnus  <burnus@net-b.de>

	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..4da21c3 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4855,6 +4855,13 @@ 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)
+    {
+      current_attr.is_bind_c = 1;
+      has_name_equals = 0;
+      curr_binding_label = NULL;
+    }
+
   /* Get procedure symbols.  */
   for(num=1;;num++)
     {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C)
  2012-03-10 15:53 ` Tobias Burnus
@ 2012-03-12  8:42   ` Paul Richard Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2012-03-12  8:42 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

Dear Tobias,

Apart from s/Contribute/Contributed/ this is OK for trunk.  In fact, I
would say that it is "obvious".

Thanks for the patch.

Paul

On Sat, Mar 10, 2012 at 4:53 PM, Tobias Burnus <burnus@net-b.de> wrote:
> Tobias Burnus wrote:
>>
>> 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)?
>
>
> Well, it didn't as I forgot to reset two variables - one then gets then an
> error that one has specified an binding name - or the wrong binding name
> might be used.
>
> Build and regtested on x86-64-linux.
> OK?
>
> Tobias



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-12  8:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09 22:00 [Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C) Tobias Burnus
2012-03-10 15:53 ` Tobias Burnus
2012-03-12  8:42   ` Paul Richard Thomas

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).