This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR34187 - Binding label got lost for private procedures of public generic procedures


Tobias Burnus wrote:
> The way modules were read, the information about the binding label of
> BIND(C) was sometimes not included.
>   
The patch and the "strncpy(dest, src, strlen(src)+1)" -> "strcpy(dest,
src)" patch were approved by Jerry on IRC.

The following was committed as Rev. 130386.

Tobias
2007-11-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34187
	* module.c (load_needed): Ensure binding_label is not lost.

	* decl.c (set_binding_label,gfc_match_bind_c): Replace
	strncpy by strcpy.

2007-11-23  Tobias Burnus  <burnus@net-b.de>
 
	PR fortran/34187
	* gfortran.dg/bind_c_usage_15.f90: New.

Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 130385)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,5 +1,10 @@
 2007-11-23  Tobias Burnus  <burnus@net-b.de>
 
+	PR fortran/34187
+	* gfortran.dg/bind_c_usage_15.f90: New.
+
+2007-11-23  Tobias Burnus  <burnus@net-b.de>
+
 	PR fortran/34192
 	* gfortran.dg/nearest_2.f90: New.
 
Index: gcc/testsuite/gfortran.dg/bind_c_usage_15.f90
===================================================================
--- gcc/testsuite/gfortran.dg/bind_c_usage_15.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/bind_c_usage_15.f90	(Revision 0)
@@ -0,0 +1,29 @@
+! { dg-do run }
+!
+! PR fortran/34187
+! The binding label was not exported for private procedures
+! with public generic interfaces.
+!
+module mod
+  use iso_c_binding, only: c_int
+  implicit none
+  private
+  public :: gen, c_int
+  interface gen
+    module procedure  test
+  end interface gen
+contains
+  subroutine test(a) bind(c, name="myFunc")
+    integer(c_int), intent(out) :: a 
+    a = 17
+  end subroutine test
+end module mod
+
+program main
+  use mod
+  implicit none
+  integer(c_int) :: x
+  x = -44
+  call gen(x)
+  if(x /= 17) call abort()
+end program main
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(Revision 130385)
+++ gcc/fortran/decl.c	(Arbeitskopie)
@@ -3126,15 +3126,14 @@ set_binding_label (char *dest_label, con
   if (curr_binding_label[0] != '\0')
     {
       /* Binding label given; store in temp holder til have sym.  */
-      strncpy (dest_label, curr_binding_label,
-               strlen (curr_binding_label) + 1);
+      strcpy (dest_label, curr_binding_label);
     }
   else
     {
       /* No binding label given, and the NAME= specifier did not exist,
          which means there was no NAME="".  */
       if (sym_name != NULL && has_name_equals == 0)
-        strncpy (dest_label, sym_name, strlen (sym_name) + 1);
+        strcpy (dest_label, sym_name);
     }
    
   return SUCCESS;
@@ -4736,12 +4735,10 @@ gfc_match_bind_c (gfc_symbol *sym)
     {
       if (sym != NULL)
       {
-	strncpy (sym->binding_label, binding_label,
-		 strlen (binding_label)+1);
+	strcpy (sym->binding_label, binding_label);
       }
       else
-	strncpy (curr_binding_label, binding_label,
-		 strlen (binding_label) + 1);
+	strcpy (curr_binding_label, binding_label);
     }
   else
     {
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 130385)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,4 +1,12 @@
 2007-11-23  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/34187
+	* module.c (load_needed): Ensure binding_label is not lost.
+
+	* decl.c (set_binding_label,gfc_match_bind_c): Replace
+	strncpy by strcpy.
+
+2007-11-23  Tobias Burnus  <burnus@net-b.de>
 	    Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	PR fortran/34192
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(Revision 130385)
+++ gcc/fortran/module.c	(Arbeitskopie)
@@ -3419,6 +3419,7 @@ load_needed (pointer_info *p)
 
       sym = gfc_new_symbol (p->u.rsym.true_name, ns);
       sym->module = gfc_get_string (p->u.rsym.module);
+      strcpy (sym->binding_label, p->u.rsym.binding_label);
 
       associate_integer_pointer (p, sym);
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]