re PR fortran/34187 (BIND(C): Public generic with private bind(c) specific does not...
authorTobias Burnus <burnus@net-b.de>
Sat, 24 Nov 2007 00:11:38 +0000 (01:11 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 24 Nov 2007 00:11:38 +0000 (01:11 +0100)
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.

From-SVN: r130386

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/module.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/bind_c_usage_15.f90 [new file with mode: 0644]

index 93f775ee0950f0fe3d01ddd078fd11758ce63358..b0fa324f984581b5af8c60b62277d69b301edce7 100644 (file)
@@ -1,3 +1,11 @@
+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>
 
index 78b05c4af1e475e7f486261a720accb343e77c82..d66ea533ca7cf3e655d75a7bbdb52a775da53553 100644 (file)
@@ -3126,15 +3126,14 @@ set_binding_label (char *dest_label, const char *sym_name, int num_idents)
   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 b0962e0b542b2bd88074dd3ea2590bc8affb1544..00b9e25954673eaa0416eb2cecabe315d7f4a216 100644 (file)
@@ -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 d87601f419dc521d39d6b9919c32f8f2518c4977..ee015a29f0065cb2be4771c0be5d7e9653806741 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_15.f90 b/gcc/testsuite/gfortran.dg/bind_c_usage_15.f90
new file mode 100644 (file)
index 0000000..c5201a6
--- /dev/null
@@ -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