Commit ba59df78 by Kriang Lerdsuwanakij Committed by Kriang Lerdsuwanakij

PR c++/4802, c++/5387

	PR c++/4802, c++/5387
	* decl.c (make_typename_type): Use enforce_access.

	* g++.dg/template/access2.C: New test.
	* g++.dg/template/access3.C: New test.

From-SVN: r55517
parent 58f05188
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
......
......@@ -5652,6 +5652,9 @@ make_typename_type (context, name, complain)
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,
......@@ -5672,6 +5675,9 @@ make_typename_type (context, name, complain)
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,
......
// { 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" }
}
// { 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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment