From d4beaf2a221eb97bc7d074b99777cd780e3e0793 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Mon, 10 Sep 2018 23:25:33 +0200 Subject: [PATCH] re PR fortran/85395 ([F03] private clause contained in derived type acquires spurious scope) fix PR 85395 2018-09-10 Janus Weil PR fortran/85395 * decl.c (match_binding_attributes): Use correct default accessibility for procedure pointer components. 2018-09-10 Janus Weil PR fortran/85395 * gfortran.dg/proc_ptr_comp_52.f90: New test case. From-SVN: r264196 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/decl.c | 3 +- gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/proc_ptr_comp_52.f90 | 33 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7cfb94ee115..97d97e845bd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-09-10 Janus Weil + + PR fortran/85395 + * decl.c (match_binding_attributes): Use correct default accessibility + for procedure pointer components. + 2018-09-03 Jerry DeLisle * simplify.c (gfc_simplify_modulo): Re-arrange code to test whether diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 03298833c98..3d19ad479e5 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -10570,7 +10570,8 @@ match_binding_attributes (gfc_typebound_proc* ba, bool generic, bool ppc) done: if (ba->access == ACCESS_UNKNOWN) - ba->access = gfc_typebound_default_access; + ba->access = ppc ? gfc_current_block()->component_access + : gfc_typebound_default_access; if (ppc && !seen_ptr) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c038441a8c..dd0f878abc5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-10 Janus Weil + + PR fortran/85395 + * gfortran.dg/proc_ptr_comp_52.f90: New test case. + 2018-09-08 Marek Polacek PR c++/87150 - wrong ctor with maybe-rvalue semantics. diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 new file mode 100644 index 00000000000..631c0180753 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! +! PR 85395: [F03] private clause contained in derived type acquires spurious scope +! +! Contributed by + +module defs + implicit none + + type :: base + contains + private + end type + + type :: options + procedure(), pointer, nopass :: ptr + end type + + type :: t + private + procedure(), pointer, nopass, public :: ptr + end type +end module + + +program p + use defs + implicit none + type(options) :: self + type(t) :: dt + self%ptr => null() + dt%ptr => null() +end -- 2.30.2