re PR c++/35986 (ICE with ambiguous template functions)
authorJakub Jelinek <jakub@redhat.com>
Wed, 30 Apr 2008 14:24:18 +0000 (16:24 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 30 Apr 2008 14:24:18 +0000 (16:24 +0200)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/template4.C [new file with mode: 0644]

index bb4c4af0b4a5838acbdd4774e8accc14c0f5c364..5289222672019be9e91e9b7e482b52d444abe326 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35986
+       * pt.c (more_specialized_fn): Stop the loop even if there are no
+       arguments before ellipsis.
+
 2008-04-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/35650
index 5ea5128e8717fba4b8ed33330dfdfe75139d91d8..b13573ce43ce4f6f8b5cc53dd5b9715be2560b5d 100644 (file)
@@ -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--;
index c7b1cf29a8974a46587ce14b946282809cde699f..b0c5d64b369d33f1052004893b9ecd20d91d1c63 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35986
+       * g++.dg/overload/template4.C: New test.
+
 2008-04-30  Kai Tietz  <kai.tietz@onevision.com>
 
        * 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 (file)
index 0000000..4c3ca05
--- /dev/null
@@ -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" }
+}