This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 29 Apr 2008 06:04:33 -0400
- Subject: [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This is just a follow-up for PR33962, I haven't realized back then that
ellipsis can occur right after the opening parenthesis, so the PR33962 patch
handled ellipsis only after some actual argument.
Fixed thusly, regtested on x86_64-linux, ok for trunk?
2008-04-29 Jakub Jelinek <jakub@redhat.com>
PR c++/35986
* pt.c (more_specialized_fn): Stop the loop even if there are no
arguments before ellipsis.
* g++.dg/overload/template4.C: New test.
--- gcc/cp/pt.c.jj 2008-04-23 21:52:57.000000000 +0200
+++ gcc/cp/pt.c 2008-04-29 11:19:29.000000000 +0200
@@ -13652,7 +13652,9 @@ more_specialized_fn (tree pat1, tree pat
processing_template_decl++;
- while (len--)
+ while (len--
+ /* Stop when an ellipsis is seen. */
+ && args1 != NULL_TREE && args2 != NULL_TREE)
{
tree arg1 = TREE_VALUE (args1);
tree arg2 = TREE_VALUE (args2);
@@ -13815,10 +13817,6 @@ more_specialized_fn (tree pat1, tree pat
args1 = TREE_CHAIN (args1);
args2 = TREE_CHAIN (args2);
-
- /* Stop when an ellipsis is seen. */
- if (args1 == NULL_TREE || args2 == NULL_TREE)
- break;
}
processing_template_decl--;
--- gcc/testsuite/g++.dg/overload/template4.C.jj 2008-04-29 11:34:33.000000000 +0200
+++ gcc/testsuite/g++.dg/overload/template4.C 2008-04-29 11:40:29.000000000 +0200
@@ -0,0 +1,21 @@
+// PR c++/35986
+// { dg-do compile }
+
+namespace
+{
+ template <int> void foo (...); // { dg-error "" "candidate" }
+ template <int> void bar (int, ...); // { dg-error "" "candidate" }
+ void baz (...); // { dg-error "" "candidate" }
+}
+
+template <int> void foo (...); // { dg-error "" "candidate" }
+template <int> void bar (int, ...); // { dg-error "" "candidate" }
+void baz (...); // { dg-error "" "candidate" }
+
+void
+test ()
+{
+ foo <0> (0); // { dg-error "is ambiguous" }
+ bar <1> (0, 1); // { dg-error "is ambiguous" }
+ baz (0); // { dg-error "is ambiguous" }
+}
Jakub