aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>2003-07-14 10:48:59 +0000
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>2003-07-14 10:48:59 +0000
commit55ece1b348b5c67402a6efa630dacfbba0bcf7cb (patch)
treeaa534e8dcff947fe6f748a9d107e23d6420d6c08
parent9a8c9b44ccb0d9a94256bfa2bf3d1cf8f1f7744f (diff)
downloadgcc-55ece1b348b5c67402a6efa630dacfbba0bcf7cb.zip
gcc-55ece1b348b5c67402a6efa630dacfbba0bcf7cb.tar.gz
gcc-55ece1b348b5c67402a6efa630dacfbba0bcf7cb.tar.bz2
re PR c++/11154 (spurious ambiguity report for template class specialization)
PR c++/11154 * pt.c (more_specialized_class): Add full_args parameter. (most_specialized_class): Adjust calls to more_specialized_class. * cp-tree.h (more_specialized_class): Adjust declaration. * g++.dg/template/partial2.C: New test. From-SVN: r69328
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/pt.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/partial2.C14
5 files changed, 36 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ea04ac8..8cc0234 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/11154
+ * pt.c (more_specialized_class): Add full_args parameter.
+ (most_specialized_class): Adjust calls to more_specialized_class.
+ * cp-tree.h (more_specialized_class): Adjust declaration.
+
2003-07-14 Dan Nicolaescu <dann@ics.uci.edu>
* lex.c (enum tree_node_kind): Delete.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 32b791f..8658be6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3968,7 +3968,7 @@ extern tree instantiate_decl (tree, int);
extern tree get_bindings (tree, tree, tree);
extern int push_tinst_level (tree);
extern void pop_tinst_level (void);
-extern int more_specialized_class (tree, tree);
+extern int more_specialized_class (tree, tree, tree);
extern int is_member_template (tree);
extern int comp_template_parms (tree, tree);
extern int template_class_depth (tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ac032d1..ee9d245 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9962,21 +9962,24 @@ more_specialized (tree pat1, tree pat2, int deduce, int len)
1 if PAT1 is more specialized than PAT2 as described in [temp.class.order].
-1 if PAT2 is more specialized than PAT1.
- 0 if neither is more specialized. */
+ 0 if neither is more specialized.
+
+ FULL_ARGS is the full set of template arguments that triggers this
+ partial ordering. */
int
-more_specialized_class (tree pat1, tree pat2)
+more_specialized_class (tree pat1, tree pat2, tree full_args)
{
tree targs;
int winner = 0;
targs = get_class_bindings (TREE_VALUE (pat1), TREE_PURPOSE (pat1),
- TREE_PURPOSE (pat2));
+ add_outermost_template_args (full_args, TREE_PURPOSE (pat2)));
if (targs)
--winner;
targs = get_class_bindings (TREE_VALUE (pat2), TREE_PURPOSE (pat2),
- TREE_PURPOSE (pat1));
+ add_outermost_template_args (full_args, TREE_PURPOSE (pat1)));
if (targs)
++winner;
@@ -10257,7 +10260,7 @@ most_specialized_class (tree tmpl, tree args)
t = TREE_CHAIN (t);
for (; t; t = TREE_CHAIN (t))
{
- fate = more_specialized_class (champ, t);
+ fate = more_specialized_class (champ, t, args);
if (fate == 1)
;
else
@@ -10274,7 +10277,7 @@ most_specialized_class (tree tmpl, tree args)
for (t = list; t && t != champ; t = TREE_CHAIN (t))
{
- fate = more_specialized_class (champ, t);
+ fate = more_specialized_class (champ, t, args);
if (fate != 1)
return error_mark_node;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e51dda8..92c235c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/11154
+ * g++.dg/template/partial2.C: New test.
+
2003-07-13 Mark Mitchell <mark@codesourcery.com>
PR c++/11503
diff --git a/gcc/testsuite/g++.dg/template/partial2.C b/gcc/testsuite/g++.dg/template/partial2.C
new file mode 100644
index 0000000..ebfdce2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial2.C
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// Origin: lorgon1@yahoo.com
+
+// PR c++/11154: Multi-level template argument in partial ordering of
+// class template
+
+template <class A> struct Outer {
+ template <class T, class U = void, class V = void> struct Foo {};
+ template <class T, class U> struct Foo<T,U,void> {};
+ template <class T> struct Foo<T,void,void> {};
+};
+
+Outer<int>::Foo<int,void,void> f;