This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 patch]: Fix 13445
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 30 Dec 2003 09:47:50 +0000
- Subject: [3.3 patch]: Fix 13445
- Organization: Codesourcery LLC
I have backported this patch to fix 13445 on the 3.3 branch.
booted & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (instantiate_class_template): Push to class's scope before
tsubsting base.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.758
diff -c -3 -p -r1.758 pt.c
*** cp/pt.c 15 Aug 2003 12:15:56 -0000 1.758
--- cp/pt.c 18 Aug 2003 12:30:40 -0000
*************** instantiate_class_template (tree type)
*** 5173,5180 ****
--- 5173,5186 ----
tree base_list = NULL_TREE;
tree pbases = BINFO_BASETYPES (pbinfo);
tree paccesses = BINFO_BASEACCESSES (pbinfo);
+ tree context = TYPE_CONTEXT (type);
int i;
+ /* We must enter the scope containing the type, as that is where
+ the accessibility of types named in dependent bases are
+ looked up from. */
+ push_scope (context ? context : global_namespace);
+
/* Substitute into each of the bases to determine the actual
basetypes. */
for (i = 0; i < TREE_VEC_LENGTH (pbases); ++i)
*************** instantiate_class_template (tree type)
*** 5201,5206 ****
--- 5207,5214 ----
/* Now call xref_basetypes to set up all the base-class
information. */
xref_basetypes (type, base_list);
+
+ pop_scope (context ? context : global_namespace);
}
/* Now that our base classes are set up, enter the scope of the
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 15 Aug 2003 <nathan@codesourcery.com>
// checked instantiated bases in wrong scope.
class Helper {};
template<class T> struct X { };
template<class T> class Base
{
protected:
typedef Helper H;
};
template<class T >
struct Derived : Base<T>
{
typedef Base<T> Parent;
typedef typename Parent::H H;
class Nested : public X<H> {};
Nested m;
void Foo ();
};
void Foo (Derived<char> &x)
{
x.Foo ();
}