aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-03-18 09:36:19 -0500
committerJason Merrill <jason@gcc.gnu.org>2002-03-18 09:36:19 -0500
commit0f4237c2da717bce4a222c696cb1ba468a3ff550 (patch)
treedb5986e8ecf6cd31ae59af52d2f151e69287d828
parent001ad76c41fb6725f6834c063199e8ea6540a9ee (diff)
downloadgcc-0f4237c2da717bce4a222c696cb1ba468a3ff550.zip
gcc-0f4237c2da717bce4a222c696cb1ba468a3ff550.tar.gz
gcc-0f4237c2da717bce4a222c696cb1ba468a3ff550.tar.bz2
re PR c++/3870 (gcc 3.0 bogus error specializing a template function)
PR c++/3870 * cp-tree.h (struct saved_scope): Add last_parms field. * decl.c (maybe_push_to_top_level): Save last_function_parms. (pop_from_top_level): Restore it. From-SVN: r50970
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/testsuite/g++.dg/template/spec3.C16
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 94682bc..c5b30b7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2002-03-18 Jason Merrill <jason@redhat.com>
+ PR c++/3870
+ * cp-tree.h (struct saved_scope): Add last_parms field.
+ * decl.c (maybe_push_to_top_level): Save last_function_parms.
+ (pop_from_top_level): Restore it.
+
PR c++/4377
* mangle.c (write_expression): Strip NOP_EXPRs sooner. Also strip
NON_LVALUE_EXPRs.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fac6a9d..6da6811 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -731,6 +731,7 @@ struct saved_scope
tree x_saved_tree;
tree incomplete;
tree lookups;
+ tree last_parms;
HOST_WIDE_INT x_processing_template_decl;
int x_processing_specialization;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 30351c9..fcc87fe 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2501,6 +2501,7 @@ maybe_push_to_top_level (pseudo)
s->bindings = b;
s->need_pop_function_context = need_pop;
s->function_decl = current_function_decl;
+ s->last_parms = last_function_parms;
scope_chain = s;
current_function_decl = NULL_TREE;
@@ -2542,6 +2543,7 @@ pop_from_top_level ()
if (s->need_pop_function_context)
pop_function_context_from (NULL_TREE);
current_function_decl = s->function_decl;
+ last_function_parms = s->last_parms;
free (s);
}
diff --git a/gcc/testsuite/g++.dg/template/spec3.C b/gcc/testsuite/g++.dg/template/spec3.C
new file mode 100644
index 0000000..d3fa401
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/spec3.C
@@ -0,0 +1,16 @@
+// PR c++/3870
+// Test that performing a type instantiation in order to match up a
+// specialization doesn't clobber last_function_parms.
+
+template <class T>
+struct A { typedef int I; };
+
+template <class T>
+inline typename T::I
+foo (typename T::I, const T*);
+
+template <>
+int foo (int i, const A<long>*)
+{
+ return i + 1;
+}