]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/3663 (G++ doesn't check access control during template instanation)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Thu, 19 Dec 2002 14:45:19 +0000 (14:45 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Thu, 19 Dec 2002 14:45:19 +0000 (14:45 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/access7.C [new file with mode: 0644]

index dbf094257ab5bdc454ea17fe0745024a74439638..042e0c0ed9d2a4486cb9f73f27ed3eed5e412db3 100644 (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
index 275605e9d9e3bb5f4f16fec0a5363e6bb0d3c428..33a84a3aa62fe8af71a47c6945d5a0fad444d40c 100644 (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.  */
index e4b303c79c53775ddff782be7cb10215f980c498..a1510c04a337daa6656a9347320ce246a4c35c0f 100644 (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
diff --git a/gcc/testsuite/g++.dg/template/access7.C b/gcc/testsuite/g++.dg/template/access7.C
new file mode 100644 (file)
index 0000000..92d4c68
--- /dev/null
@@ -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" }
+}
This page took 0.139204 seconds and 5 git commands to generate.