Patchwork [Fortran] PR 52542 - Fix PROCEDURE() with Bind(C)

login
register
mail settings
Submitter Tobias Burnus
Date March 9, 2012, 10 p.m.
Message ID <4F5A7D83.9010203@net-b.de>
Download mbox | patch
Permalink /patch/145767/
State New
Headers show

Comments

Tobias Burnus - March 9, 2012, 10 p.m.
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

Patch

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