pt.c (instantiate_class_template): Push to class's scope before tsubsting base.

cp:
	* pt.c (instantiate_class_template): Push to class's scope before
	tsubsting base.
testsuite:
	* g++.dg/template/scope2.C: New test.
	* g++.dg/template/error2.C: Correct dg-error

From-SVN: r70540
This commit is contained in:
Nathan Sidwell 2003-08-18 12:44:22 +00:00 committed by Nathan Sidwell
parent 5d87256426
commit a2507277ed
5 changed files with 53 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (instantiate_class_template): Push to class's scope before
tsubsting base.
Sun Aug 17 10:05:38 CEST 2003 Jan Hubicka <jh@suse.cz>
PR C++/11702

View File

@ -5173,8 +5173,14 @@ instantiate_class_template (tree type)
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)
@ -5201,6 +5207,8 @@ instantiate_class_template (tree type)
/* 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

View File

@ -1,3 +1,8 @@
2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/template/scope2.C: New test.
* g++.dg/template/error2.C: Correct dg-error
2003-08-18 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/compile/mipscop*.c: Turn into compile-only tests.

View File

@ -14,7 +14,7 @@ template<class T >
struct Derived
{
class Nested : public X<T>
{ // { dg-error "instantiated"
{ // { dg-error "instantiated" "" }
};
Nested m; // { dg-error "instantiated" "" }

View File

@ -0,0 +1,34 @@
// { 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 ();
}