diff mbox series

PR fortran/86587 -- PRIVATE and BIND(C) are allowed for derived type

Message ID 20190619211052.GA99095@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/86587 -- PRIVATE and BIND(C) are allowed for derived type | expand

Commit Message

Steve Kargl June 19, 2019, 9:10 p.m. UTC
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  <kargl@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  <kargl@gcc.gnu.org>

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

Comments

Janne Blomqvist June 20, 2019, 8:17 p.m. UTC | #1
On Thu, Jun 20, 2019 at 12:10 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> 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  <kargl@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  <kargl@gcc.gnu.org>
>
>         PR fortran/86587
>         * gfortran.dg/pr86587.f90: New test.
>
> --
> Steve

Ok.
diff mbox series

Patch

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