re PR fortran/40089 (Public type with public component which has a private type)
authorJanus Weil <janus@gcc.gnu.org>
Mon, 11 May 2009 14:14:38 +0000 (16:14 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Mon, 11 May 2009 14:14:38 +0000 (16:14 +0200)
2009-05-11  Janus Weil  <janus@gcc.gnu.org>

PR fortran/40089
* resolve.c (resolve_fl_derived): Only return FAILURE if
gfc_notify_std fails.

2009-05-11  Janus Weil  <janus@gcc.gnu.org>

PR fortran/40089
* gfortran.dg/proc_ptr_comp_7.f90: New.

From-SVN: r147379

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

index 97f56b20141da3bbdf1357eccb48d9f68a6f9190..d79ea175dec5bf491c8c77418e0dd55c09cb9806 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-11  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/40089
+       * resolve.c (resolve_fl_derived): Only return FAILURE if
+       gfc_notify_std fails.
+
 2009-05-10  Ian Lance Taylor  <iant@google.com>
 
        * gfortran.h (enum gfc_omp_sched_kind): New enum, broken out of
index 34cb365a5629ddc3a1a8b4dd9771a1e1d1ea2ee8..29d4b3aa207741a53b2cf385d3d3e89d614a90df 100644 (file)
@@ -9086,14 +9086,12 @@ resolve_fl_derived (gfc_symbol *sym)
          && !is_sym_host_assoc (c->ts.derived, sym->ns)
          && !c->ts.derived->attr.use_assoc
          && !gfc_check_access (c->ts.derived->attr.access,
-                               c->ts.derived->ns->default_access))
-       {
-         gfc_notify_std (GFC_STD_F2003, "Fortran 2003: the component '%s' "
-                         "is a PRIVATE type and cannot be a component of "
-                         "'%s', which is PUBLIC at %L", c->name,
-                         sym->name, &sym->declared_at);
-         return FAILURE;
-       }
+                               c->ts.derived->ns->default_access)
+         && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: the component '%s' "
+                            "is a PRIVATE type and cannot be a component of "
+                            "'%s', which is PUBLIC at %L", c->name,
+                            sym->name, &sym->declared_at) == FAILURE)
+       return FAILURE;
 
       if (sym->attr.sequence)
        {
index 1ccd97a548ad37b860bdb8c579c840fe926cf820..f8365a0f95d89b7b2ed2d9f48bce6005f03129b6 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-11  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/40089
+       * gfortran.dg/proc_ptr_comp_7.f90: New.
+
 2009-05-11  Ira Rosen  <irar@il.ibm.com>
 
        PR tree-optimization/40074
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_7.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_7.f90
new file mode 100644 (file)
index 0000000..860c2dd
--- /dev/null
@@ -0,0 +1,40 @@
+! { dg-do compile }
+!
+! PR 40089: Public type with public component which has a private type
+!
+! Original test case by Juergen Reuter <reuter@physik.uni-freiburg.de>
+! Adapted by Janus Weil <janus@gcc.gnu.org>
+
+module m
+
+  implicit none
+  private
+
+  public :: public_t
+
+  type :: private_t
+    integer :: i
+  end type
+
+  type :: public_t
+     type(private_t), pointer :: public_comp_with_private_type
+     procedure(ifc) , nopass, pointer :: ppc
+  end type
+
+  abstract interface
+     integer function ifc ()
+     end function
+  end interface
+
+end module m
+
+program test
+use m
+implicit none
+type(public_t) :: x
+integer :: j
+j = x%ppc()
+end
+
+! { dg-final { cleanup-modules "m" } }
+