This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR 40089: Public type with public component which has a private type


Hi all,

this small patch fixes a close-to-obvious bug in resolve.c
(resolve_fl_derived), which triggered a rejects-valid error with
procedure pointer components. For details see the PR. Regtested on
x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


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/39996
	* gfortran.dg/proc_ptr_comp_7.f90: New.
Index: gcc/testsuite/gfortran.dg/proc_ptr_comp_7.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_comp_7.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/proc_ptr_comp_7.f90	(revision 0)
@@ -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" } }
+
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 147364)
+++ gcc/fortran/resolve.c	(working copy)
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]