re PR fortran/85395 ([F03] private clause contained in derived type acquires spurious...
authorJanus Weil <janus@gcc.gnu.org>
Mon, 10 Sep 2018 21:25:33 +0000 (23:25 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Mon, 10 Sep 2018 21:25:33 +0000 (23:25 +0200)
fix PR 85395

2018-09-10  Janus Weil  <janus@gcc.gnu.org>

PR fortran/85395
* decl.c (match_binding_attributes): Use correct default accessibility
for procedure pointer components.

2018-09-10  Janus Weil  <janus@gcc.gnu.org>

PR fortran/85395
* gfortran.dg/proc_ptr_comp_52.f90: New test case.

From-SVN: r264196

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/proc_ptr_comp_52.f90 [new file with mode: 0644]

index 7cfb94ee1152ac9d5061cfd58d67d40e46dd1bb1..97d97e845bd27c4e82623e08743704b03f0f47bd 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/85395
+       * decl.c (match_binding_attributes): Use correct default accessibility
+       for procedure pointer components.
+
 2018-09-03  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        * simplify.c (gfc_simplify_modulo): Re-arrange code to test whether
index 03298833c98d5ad4a74c3ff05616c06c38c255f3..3d19ad479e5d70abc3bbe448561d3b3e8214d492 100644 (file)
@@ -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)
     {
index 0c038441a8c5089c38abbd7bc7670c9fa3c4a332..dd0f878abc59384ce8652f535ad10ed1b33fa5cb 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-10  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/85395
+       * gfortran.dg/proc_ptr_comp_52.f90: New test case.
+
 2018-09-08  Marek Polacek  <polacek@redhat.com>
 
        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 (file)
index 0000000..631c018
--- /dev/null
@@ -0,0 +1,33 @@
+! { dg-do compile }
+!
+! PR 85395: [F03] private clause contained in derived type acquires spurious scope
+!
+! Contributed by <cfd@mnet-mail.de>
+
+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