Commit a2507277 by Nathan Sidwell Committed by Nathan Sidwell

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
parent 5d872564
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
......
......@@ -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
......
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.
......
......@@ -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" "" }
......
// { 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment