From 966e7f731ef7ea019e681b7b53421c6857315c4a Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 20 Jun 2019 21:39:43 +0000 Subject: [PATCH] re PR fortran/86587 (Derived-type with attributes BIND(C) and PRIVATE raises an error but standard accepts it) 2019-06-20 Steven G. Kargl PR fortran/86587 * symbol.c (verify_bind_c_derived_type): Remove erroneous error checking for BIND(C) and PRIVATE attributes. 2019-06-20 Steven G. Kargl PR fortran/86587 * gfortran.dg/pr86587.f90: New test. From-SVN: r272524 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/symbol.c | 10 ---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr86587.f90 | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr86587.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 30bf112bdab..7b71ee43e0b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-06-20 Steven G. Kargl + + PR fortran/86587 + * symbol.c (verify_bind_c_derived_type): Remove erroneous error + checking for BIND(C) and PRIVATE attributes. + 2019-06-20 Thomas Koenig PR fortran/90937 diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index ec753229a98..f4273633db7 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -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 " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3c2205da53..c6130e5eea2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-20 Steven G. Kargl + + PR fortran/86587 + * gfortran.dg/pr86587.f90: New test. + 2019-06-20 Iain Sandoe * obj-c++.dg/stubify-1.mm: Adjust options and scan-asm checks. diff --git a/gcc/testsuite/gfortran.dg/pr86587.f90 b/gcc/testsuite/gfortran.dg/pr86587.f90 new file mode 100644 index 00000000000..fb213352bb9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr86587.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/86587 +! Code contirubted by Valentin Clement +! +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 -- 2.30.2