summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/error2.C2
-rw-r--r--gcc/testsuite/g++.dg/template/scope2.C34
5 files changed, 53 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4a3d9819e69..19562e612a6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d97463bc390..e0dfcb78774 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 504682624eb..6a38f18f506 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/template/error2.C b/gcc/testsuite/g++.dg/template/error2.C
index 1ce9b6f5174..0f3e975cd4f 100644
--- a/gcc/testsuite/g++.dg/template/error2.C
+++ b/gcc/testsuite/g++.dg/template/error2.C
@@ -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" "" }
diff --git a/gcc/testsuite/g++.dg/template/scope2.C b/gcc/testsuite/g++.dg/template/scope2.C
new file mode 100644
index 00000000000..79b520cbeab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/scope2.C
@@ -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 ();
+}