]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13262 ("xxx is private within this context" when initializing a *self-conta...
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Thu, 18 Dec 2003 14:27:49 +0000 (14:27 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Thu, 18 Dec 2003 14:27:49 +0000 (14:27 +0000)
PR c++/13262
* pt.c (instantiate_decl): Wrap push_nested_class and
pop_nested_class around cp_finish_decl call for static member
variable.

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

From-SVN: r74782

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog

index 6a14a2c76717fae96cfb87b48bdc4ff04ee4fc46..61f318fa7578359ffdcad4b9351cb8219fb7ca94 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-18  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/13262
+       * pt.c (instantiate_decl): Wrap push_nested_class and
+       pop_nested_class around cp_finish_decl call for static member
+       variable.
+
 2003-12-06  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/13323
index c4a6f4ea4ae761c7043a6aed0d7b438b385895d4..e90b7ed825c5801d0686f363d479d6420f7b6272 100644 (file)
@@ -10484,10 +10484,20 @@ instantiate_decl (d, defer_ok)
          /* Mark D as instantiated so that recursive calls to
             instantiate_decl do not try to instantiate it again.  */
          DECL_TEMPLATE_INSTANTIATED (d) = 1;
+         /* This is done in analogous to `start_decl'.  It is
+            required for correct access checking.  */
+         push_nested_class (DECL_CONTEXT (d), 2);
          cp_finish_decl (d, 
                          (!DECL_INITIALIZED_IN_CLASS_P (d) 
                           ? DECL_INITIAL (d) : NULL_TREE),
                          NULL_TREE, 0);
+         /* Normally, pop_nested_class is called by cp_finish_decl
+            above.  But when instantiate_decl is triggered during
+            instantiate_class_template processing, its DECL_CONTEXT
+            is still not completed yet, and pop_nested_class isn't
+            called.  */
+         if (!COMPLETE_TYPE_P (DECL_CONTEXT (d)))
+           pop_nested_class ();
        }
     }
   else if (TREE_CODE (d) == FUNCTION_DECL)
index 5c85f0730dee2df3701845b457a58a3199b6413e..8291482ffc59a09b490b265129451f9156ba3c0f 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-18  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/13262
+       * g++.dg/template/access13.C: New test.
+
 2003-12-16  Zack Weinberg  <zack@codesourcery.com>
 
        * gcc.c-torture/compile/981223-1.x: Add -mb-step to command line