Revision 126185 introduced ISO C Binding to gfortran.
In that revision, a check for a conflict between a
derived type with the PRIVATE attribute and BIND(C) was
introduced.  After checking the F2003, F2008, and F2018
standards, I cannot find this restriction.  Thus, the
check is removed by the attached patch.  Regression 
checked on x86_64-*-freebsd.  OK to commit?

2019-06-19  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/86587
        * symbol.c (verify_bind_c_derived_type): Remove erroneous error
        checking for BIND(C) and PRIVATE attributes.

2019-06-19  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/86587
        * gfortran.dg/pr86587.f90: New test.

-- 
Steve
Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 272481)
+++ gcc/fortran/symbol.c	(working copy)
@@ -4529,16 +4529,6 @@ verify_bind_c_derived_type (gfc_symbol *derived_sym)
       curr_comp = curr_comp->next;
     } while (curr_comp != NULL);
 
-
-  /* Make sure we don't have conflicts with the attributes.  */
-  if (derived_sym->attr.access == ACCESS_PRIVATE)
-    {
-      gfc_error ("Derived type %qs at %L cannot be declared with both "
-                 "PRIVATE and BIND(C) attributes", derived_sym->name,
-                 &(derived_sym->declared_at));
-      retval = false;
-    }
-
   if (derived_sym->attr.sequence != 0)
     {
       gfc_error ("Derived type %qs at %L cannot have the SEQUENCE "
Index: gcc/testsuite/gfortran.dg/pr86587.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr86587.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr86587.f90	(working copy)
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! PR fortran/86587
+! Code contirubted by Valentin Clement <valentin.clement at env dot ethz dot ch>
+!
+module mod1
+   use iso_c_binding
+   type, bind(c), private :: mytype
+      integer(c_int) :: i1, i2
+   end type
+end module mod1
+
+module mod2
+  use iso_c_binding
+  private
+  type, bind(c) :: mytype
+    integer(c_int) :: i1, i2
+  end type
+end module mod2

Reply via email to