From: Jakub Jelinek Date: Wed, 30 Apr 2008 14:24:18 +0000 (+0200) Subject: re PR c++/35986 (ICE with ambiguous template functions) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56b1a55446a0646c53a2474be6051acf592e1da7;p=gcc.git re PR c++/35986 (ICE with ambiguous template functions) 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. From-SVN: r134823 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bb4c4af0b4a..52892226720 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-30 Jakub Jelinek + + PR c++/35986 + * pt.c (more_specialized_fn): Stop the loop even if there are no + arguments before ellipsis. + 2008-04-29 Jakub Jelinek PR c++/35650 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5ea5128e871..b13573ce43c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13652,7 +13652,9 @@ more_specialized_fn (tree pat1, tree pat2, int len) 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 pat2, int len) 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--; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c7b1cf29a89..b0c5d64b369 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-30 Jakub Jelinek + + PR c++/35986 + * g++.dg/overload/template4.C: New test. + 2008-04-30 Kai Tietz * gfortran.dg/chmod_1.f90: Disable for x86_64-*-mingw*. diff --git a/gcc/testsuite/g++.dg/overload/template4.C b/gcc/testsuite/g++.dg/overload/template4.C new file mode 100644 index 00000000000..4c3ca05e6c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/template4.C @@ -0,0 +1,21 @@ +// PR c++/35986 +// { dg-do compile } + +namespace +{ + template void foo (...); // { dg-error "" "candidate" } + template void bar (int, ...); // { dg-error "" "candidate" } + void baz (...); // { dg-error "" "candidate" } +} + +template void foo (...); // { dg-error "" "candidate" } +template 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" } +}