From 16d09dab1e7b7837c9d726ad38e9cbfc49178be0 Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Thu, 18 Dec 2003 14:27:49 +0000 Subject: [PATCH] re PR c++/13262 ("xxx is private within this context" when initializing a *self-contained* template class) 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 | 7 +++++++ gcc/cp/pt.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6a14a2c76717..61f318fa7578 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-12-18 Kriang Lerdsuwanakij + + 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 PR c++/13323 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c4a6f4ea4ae7..e90b7ed825c5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c85f0730dee..8291482ffc59 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-12-18 Kriang Lerdsuwanakij + + PR c++/13262 + * g++.dg/template/access13.C: New test. + 2003-12-16 Zack Weinberg * gcc.c-torture/compile/981223-1.x: Add -mb-step to command line -- 2.47.2