public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope
@ 2018-09-09 16:31 Janus Weil
  2018-09-10  6:55 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2018-09-09 16:31 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

Hi all,

the attached patch fixes a problem with the accessibility of procedure
pointer components (private/public attribute). It is rather
straightforward and regtest cleanly on x86_64-linux-gnu (for further
details see the PR). Ok for trunk?

Cheers,
Janus

[-- Attachment #2: pr85395.diff --]
[-- Type: text/x-patch, Size: 2169 bytes --]

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 7cfb94ee115..11adc5d13d5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-09  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
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..118c03f17f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-09  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
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 <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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope
  2018-09-09 16:31 [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope Janus Weil
@ 2018-09-10  6:55 ` Paul Richard Thomas
  2018-09-10 21:27   ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2018-09-10  6:55 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Hi Janus,

That's OK for trunk and, I would suggest 8-branch.

Thanks for the patch.

Paul


On 9 September 2018 at 17:31, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi all,
>
> the attached patch fixes a problem with the accessibility of procedure
> pointer components (private/public attribute). It is rather
> straightforward and regtest cleanly on x86_64-linux-gnu (for further
> details see the PR). Ok for trunk?
>
> Cheers,
> Janus



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope
  2018-09-10  6:55 ` Paul Richard Thomas
@ 2018-09-10 21:27   ` Janus Weil
  0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2018-09-10 21:27 UTC (permalink / raw)
  To: Paul Thomas; +Cc: gfortran, gcc-patches

Am Mo., 10. Sep. 2018 um 08:55 Uhr schrieb Paul Richard Thomas
<paul.richard.thomas@gmail.com>:
>
> Hi Janus,
>
> That's OK for trunk and, I would suggest 8-branch.

Thanks, Paul. Committed to trunk as r264196. Will backport to 8-branch
in a week or so.

Cheers,
Janus



> On 9 September 2018 at 17:31, Janus Weil <janus@gcc.gnu.org> wrote:
> > Hi all,
> >
> > the attached patch fixes a problem with the accessibility of procedure
> > pointer components (private/public attribute). It is rather
> > straightforward and regtest cleanly on x86_64-linux-gnu (for further
> > details see the PR). Ok for trunk?
> >
> > Cheers,
> > Janus
>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-10 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 16:31 [Patch, Fortran, F03] PR 85395: private clause contained in derived type acquires spurious scope Janus Weil
2018-09-10  6:55 ` Paul Richard Thomas
2018-09-10 21:27   ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).