diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 8d5bcfac932d19e323d53be479c773e7f144ce01..24ba2ecf16ebcd033944b43cf4cc5355fbd6da76 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-17  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/33106
+	* resolve.c (resolve_symbol): Reject public variable of
+	private derived-types for Fortran 95.
+
 2007-09-17  Tobias Burnus  <burnus@net-b.de>
 
 	* resolve.c (resolve_fl_procedure): Allow private dummies
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index a2444a348946157c945d8c73333054a637b9a9d7..40c476a56f0e5ca4fb13a24bea78761b18db858e 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7581,6 +7581,22 @@ resolve_symbol (gfc_symbol *sym)
       return;
     }
 
+  /* Unless the derived-type declaration is use associated, Fortran 95
+     does not allow public entries of private derived types.
+     See 4.4.1 (F95) and 4.5.1.1 (F2003); and related interpretation
+     161 in 95-006r3.  */
+  if (sym->ts.type == BT_DERIVED
+      && gfc_check_access (sym->attr.access, sym->ns->default_access)
+      && !gfc_check_access (sym->ts.derived->attr.access,
+			    sym->ts.derived->ns->default_access)
+      && !sym->ts.derived->attr.use_assoc
+      && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PUBLIC %s '%s' at %L "
+		         "of PRIVATE derived type '%s'",
+			 (sym->attr.flavor == FL_PARAMETER) ? "parameter"
+			 : "variable", sym->name, &sym->declared_at,
+			 sym->ts.derived->name) == FAILURE)
+    return;
+
   /* An assumed-size array with INTENT(OUT) shall not be of a type for which
      default initialization is defined (5.1.2.4.4).  */
   if (sym->ts.type == BT_DERIVED
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7bd5c28904e5aec05e24cfc4cc748966cd78b8d3..ae89416b95bd0be320f23282b548a56618852ee4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-17  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/33106
+	* gfortran.dg/private_type_9.f90: New.
+
 2007-09-17  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
 	PR middle-end/33449
diff --git a/gcc/testsuite/gfortran.dg/private_type_9.f90 b/gcc/testsuite/gfortran.dg/private_type_9.f90
new file mode 100644
index 0000000000000000000000000000000000000000..078041ae0bec19651befa2639b8c085d5e8b9d84
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/private_type_9.f90
@@ -0,0 +1,41 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+!
+! PR fortran/33106
+!
+module m1
+  implicit none
+  type, private :: t
+    integer :: i
+  end type t
+  type(t), public :: one ! { dg-error "PRIVATE derived type" }
+  type(t), public, parameter :: two = t(2) ! { dg-error "PRIVATE derived type" }
+end module m1
+
+module m2
+  implicit none
+  private
+  type t
+    integer :: i
+  end type t
+  type(t), public :: one ! { dg-error "PRIVATE derived type" }
+  type(t), public, parameter :: two = t(2) ! { dg-error "PRIVATE derived type" }
+end module m2
+
+module m3
+  implicit none
+  type t
+    integer :: i
+  end type t
+end module m3
+
+module m4
+  use m3!, only: t
+  implicit none
+  private 
+  private :: t
+  type(t), public :: one
+  type(t), public, parameter :: two = t(2)
+end module m4
+
+end