[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 janus at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #11 from janus at gcc dot gnu.org --- Fixed on 9-trunk and 8-branch. Closing.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #10 from janus at gcc dot gnu.org --- Author: janus Date: Tue Sep 18 19:50:17 2018 New Revision: 264410 URL: https://gcc.gnu.org/viewcvs?rev=264410=gcc=rev Log: 2018-09-18 Janus Weil Backport from trunk PR fortran/85395 * decl.c (match_binding_attributes): Use correct default accessibility for procedure pointer components. 2018-09-18 Janus Weil Backport from trunk PR fortran/85395 * gfortran.dg/proc_ptr_comp_52.f90: New test case. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/decl.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #9 from janus at gcc dot gnu.org --- Author: janus Date: Mon Sep 10 21:25:33 2018 New Revision: 264196 URL: https://gcc.gnu.org/viewcvs?rev=264196=gcc=rev Log: 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. Added: trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #8 from janus at gcc dot gnu.org --- This should finally be the proper fix: 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) {
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #7 from janus at gcc dot gnu.org --- (In reply to janus from comment #6) > I have verified that the patch in comment 5 shows no failures in the > testsuite. Despite that, it's still not fully correct. In fact it rejects the following test case: module m implicit none type :: t private procedure(), pointer, nopass, public :: ptr end type end module program p use m implicit none type(t) :: dt dt%ptr => null() end I'm surprised that the testsuite does not seem to cover such a case.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #6 from janus at gcc dot gnu.org --- I have verified that the patch in comment 5 shows no failures in the testsuite.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 --- Comment #5 from janus at gcc dot gnu.org --- The following patch also fixes the problem: diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 03298833c98..83fc6c29b5a 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6754,7 +6754,7 @@ match_ppc_decl (void) gfc_clear_attr (_attr); current_attr.procedure = 1; current_attr.proc_pointer = 1; - current_attr.access = tb->access; + current_attr.access = gfc_current_block()->component_access; current_attr.flavor = FL_PROCEDURE; /* Match the colons (required). */ I think this approach is better than the one in comment 4. There are two kinds of default access: One for components, one for type-bound procedures. For procedure-pointer components, gfortran currently applies the TBP default access. I think this is wrong (since PPCs are declared in the component part, not in the TBP part of a type declaration). The above patch fixes it.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 janus at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |janus at gcc dot gnu.org --- Comment #4 from janus at gcc dot gnu.org --- The problem can be fixed with this patch: diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 13cc6f5fccd..5f0d181d728 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -3267,6 +3267,7 @@ parse_derived (void) push_state (, COMP_DERIVED, gfc_new_block); gfc_new_block->component_access = ACCESS_PUBLIC; + gfc_typebound_default_access = ACCESS_PUBLIC; seen_private = 0; seen_sequence = 0; seen_component = 0; I'm not sure if this is the best way to fix it, though.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 janus at gcc dot gnu.org changed: What|Removed |Added Keywords||rejects-valid CC||janus at gcc dot gnu.org --- Comment #3 from janus at gcc dot gnu.org --- Slightly reduced test case: module defs implicit none type :: base ! this is ok ! private contains ! This private clause acquires spurious scope private end type type :: options integer :: i procedure(), pointer, nopass :: ptr end type end module program p use defs implicit none type(options) :: self self%i = 0 self%ptr => null() end Two observations: 1) The problem only occurs if the PRIVATE statement comes after CONTAINS (not before). 2) It only affects procedure pointer components, but not normal data components.
[Bug fortran/85395] [F03] private clause contained in derived type acquires spurious scope
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85395 Dominique d'Humieres changed: What|Removed |Added Summary|private clause contained in |[F03] private clause |derived type acquires |contained in derived type |spurious scope |acquires spurious scope --- Comment #2 from Dominique d'Humieres --- Adjust summary.