--- /dev/null
+diff -cprN gcc-33-save/gcc/cp/search.c gcc-33-new/gcc/cp/search.c
+*** gcc-33-save/gcc/cp/search.c Thu May 22 19:19:30 2003
+--- gcc-33-new/gcc/cp/search.c Sat May 24 19:03:32 2003
+*************** type_access_control (type, val)
+*** 1020,1026 ****
+ {
+ if (val == NULL_TREE
+ || (TREE_CODE (val) != TEMPLATE_DECL && TREE_CODE (val) != TYPE_DECL)
+! || ! DECL_CLASS_SCOPE_P (val))
+ return;
+
+ if (type_lookups == error_mark_node)
+--- 1020,1027 ----
+ {
+ if (val == NULL_TREE
+ || (TREE_CODE (val) != TEMPLATE_DECL && TREE_CODE (val) != TYPE_DECL)
+! || ! DECL_CLASS_SCOPE_P (val)
+! || processing_specialization)
+ return;
+
+ if (type_lookups == error_mark_node)
+diff -cprN gcc-33-save/gcc/testsuite/g++.dg/template/access10.C gcc-33-new/gcc/testsuite/g++.dg/template/access10.C
+*** gcc-33-save/gcc/testsuite/g++.dg/template/access10.C Thu Jan 1 07:00:00 1970
+--- gcc-33-new/gcc/testsuite/g++.dg/template/access10.C Sat May 24 23:26:59 2003
+***************
+*** 0 ****
+--- 1,16 ----
++ // { dg-do compile }
++
++ // Origin: Giovanni Bajo <giovannibajo@libero.it>
++
++ // PR c++/10849: Incorrect access checking on template specialization.
++
++ class X {
++ private:
++ template <typename T> struct Y;
++ };
++
++ template <> struct X::Y<int> {};
++
++ template <typename T> struct X::Y {};
++
++ template struct X::Y<int>;