* decl.c (make_typename_type): Use enforce_access.
* g++.dg/template/access2.C: New test.
* g++.dg/template/access3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55517
138bc75d-0d04-0410-961f-
82ee72b054a4
+2002-07-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/4802, c++/5387
+ * decl.c (make_typename_type): Use enforce_access.
+
2002-07-17 Scott Snyder <snyder@fnal.gov>
PR c++/7320
return error_mark_node;
}
+ if (!enforce_access (context, tmpl))
+ return error_mark_node;
+
return lookup_template_class (tmpl,
TREE_OPERAND (fullname, 1),
NULL_TREE, context,
t = lookup_field (context, name, 0, 1);
if (t)
{
+ if (!enforce_access (context, t))
+ return error_mark_node;
+
if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl))
t = TREE_TYPE (t);
if (IMPLICIT_TYPENAME_P (t))
+2002-07-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ * g++.dg/template/access2.C: New test.
+ * g++.dg/template/access3.C: New test.
+
2002-07-15 Zack Weinberg <zack@codesourcery.com>
* c-torture/execute/991216-3.c, c-torture/execute/strct-varg-1.c,
--- /dev/null
+// { dg-do compile }
+
+// PR c++/5387
+// Enforcing access of typename type.
+
+template <class T> struct A {
+ typename T::X x; // { dg-error "this context" }
+ int f() { return T::i; } // { dg-error "this context" }
+};
+
+class B {
+ typedef int X; // { dg-error "private" }
+ static int i; // { dg-error "private" }
+};
+
+int main()
+{
+ A<B> ab; // { dg-error "instantiated" }
+ ab.f(); // { dg-error "instantiated" }
+}
--- /dev/null
+// { dg-do compile }
+
+// PR c++/5387
+// Enforcing access of typename type.
+
+template <class T> struct A {
+ typename T::X<int> x; // { dg-error "this context" }
+};
+
+class B {
+ template <class T> class X {}; // { dg-error "private" }
+};
+
+int main()
+{
+ A<B> ab; // { dg-error "instantiated" }
+}