re PR c++/3663 (G++ doesn't check access control during template instanation)

PR c++/3663
	* pt.c (lookup_template_class): Copy TREE_PRIVATE and
	TREE_PROTECTED to created decl nodes.

	* g++.dg/template/access7.C: New test.

From-SVN: r60307
This commit is contained in:
Kriang Lerdsuwanakij 2002-12-19 14:45:19 +00:00 committed by Kriang Lerdsuwanakij
parent 7f60195472
commit cab7a9a3b9
4 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2002-12-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/3663
* pt.c (lookup_template_class): Copy TREE_PRIVATE and
TREE_PROTECTED to created decl nodes.
2002-12-18 Mark Mitchell <mark@codesourcery.com>
* class.c (build_base_field): Do not set DECL_PACKED on the

View File

@ -4235,6 +4235,11 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
else
type_decl = TYPE_NAME (t);
TREE_PRIVATE (type_decl)
= TREE_PRIVATE (TYPE_STUB_DECL (template_type));
TREE_PROTECTED (type_decl)
= TREE_PROTECTED (TYPE_STUB_DECL (template_type));
/* Set up the template information. We have to figure out which
template is the immediate parent if this is a full
instantiation. */

View File

@ -1,3 +1,8 @@
2002-11-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/3663
* g++.dg/template/access7.C: New test.
2002-12-18 Nick Clifton <nickc@redhat.com>
* lib/g++.exp (g++_include_flags): Only invoke testsuite_flags if

View File

@ -0,0 +1,18 @@
// { dg-do compile }
// PR c++/3663
// Enforce access of nested type.
template <typename A>
class S {
class T {}; // { dg-error "private" }
};
template <typename A>
typename A::T* f (A) { // { dg-error "this context" }
return 0;
}
void g () {
f (S<int> ()); // { dg-error "context|instantiated" }
}