This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Fix PR3663


Hi

The append patch fixes another C++ access checking problem in GCC.
When tsubst'ing types nested inside a template class, we forget
to propagate access to the substituted types.

Bootstrapped and tested on i686-pc-linux-gnu with no regressions.
OK to commit to main trunk?

--Kriang


2002-11-16  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-11-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

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


diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Sat Nov 16 16:18:26 2002
--- gcc-main-new/gcc/cp/pt.c	Sat Nov 16 15:50:11 2002
*************** lookup_template_class (d1, arglist, in_d
*** 4230,4235 ****
--- 4230,4240 ----
        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.  */
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/access7.C gcc-main-new/gcc/testsuite/g++.dg/template/access7.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/access7.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/access7.C	Sat Nov 16 16:21:57 2002
***************
*** 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" }
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]