* [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986)
@ 2008-04-29 12:55 Jakub Jelinek
2008-04-29 14:25 ` Mark Mitchell
2008-04-30 22:41 ` Jason Merrill
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2008-04-29 12:55 UTC (permalink / raw)
To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986)
2008-04-29 12:55 [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986) Jakub Jelinek
@ 2008-04-29 14:25 ` Mark Mitchell
2008-04-30 22:41 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2008-04-29 14:25 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches
OK. Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
On Apr 29, 2008, at 3:04 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986)
2008-04-29 12:55 [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986) Jakub Jelinek
2008-04-29 14:25 ` Mark Mitchell
@ 2008-04-30 22:41 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2008-04-30 22:41 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Mark Mitchell, gcc-patches
OK.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-30 19:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-29 12:55 [C++ PATCH] Fix more_specialized_fn for fns with ellipsis without any args before it (PR c++/35986) Jakub Jelinek
2008-04-29 14:25 ` Mark Mitchell
2008-04-30 22:41 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).