+2005-10-20 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/22618
+ * search.c (accessible_p): Check access in the outermost set of
+ template parameters.
+
2005-10-20 Richard Guenther <rguenther@suse.de>
* decl.c (grokdeclarator): Fix ambiguous pedwarn message.
/* In a template declaration, we cannot be sure whether the
particular specialization that is instantiated will be a friend
or not. Therefore, all access checks are deferred until
- instantiation. */
- if (processing_template_decl)
+ instantiation. However, PROCESSING_TEMPLATE_DECL is set in the
+ parameter list for a template (because we may see dependent types
+ in default arguments for template parameters), and access
+ checking should be performed in the outermost parameter list. */
+ if (processing_template_decl
+ && (!processing_template_parmlist || processing_template_decl > 1))
return 1;
if (!TYPE_P (type))
--- /dev/null
+// PR c++/22618
+
+class foo
+{
+ typedef int memfun; // { dg-error "private" }
+};
+
+template<foo::memfun> // { dg-error "context" }
+struct fm_obj { };
+
+template <typename T = foo::memfun> // { dg-error "context" }
+struct S {};