re PR c++/41468 (SFINAE for expressions doesn't consider ambiguous conversion sequences)
authorJason Merrill <jason@redhat.com>
Tue, 27 Apr 2010 19:04:23 +0000 (15:04 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Apr 2010 19:04:23 +0000 (15:04 -0400)
PR c++/41468
* call.c (convert_like_real) [ck_ambig]: Just return error_mark_node
if we don't want errors.

From-SVN: r158799

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/sfinae18.C [new file with mode: 0644]

index d4b82a9a20ac3ba504b43404a14a42ac3846333b..f7456bf3d521ac3ddee9c28775eb77ff3105e0b6 100644 (file)
@@ -1,5 +1,9 @@
 2010-04-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/41468
+       * call.c (convert_like_real) [ck_ambig]: Just return error_mark_node
+       if we don't want errors.
+
        PR c++/41468
        * class.c (convert_to_base): Add complain parameter.  Pass
        ba_quiet to lookup_base if we don't want errors.
index a97f7dcea108b78e078df211d499d9ceaf9f3437..7915417bd6ed9db8345a611f0301d04357867cf1 100644 (file)
@@ -4947,6 +4947,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
         }
       return expr;
     case ck_ambig:
+      if (!(complain & tf_error))
+       return error_mark_node;
       /* Call build_user_type_conversion again for the error.  */
       return build_user_type_conversion
        (totype, convs->u.expr, LOOKUP_NORMAL);
index ce7206a007c934b39599d57a82161e031fad18c6..c48c0fe8bbb6249d61ad7027b697919895fc631e 100644 (file)
@@ -2,6 +2,7 @@
 
        PR c++/41468
        * g++.dg/template/sfinae17.C: New.
+       * g++.dg/template/sfinae18.C: New.
 
 2010-04-27  Fabien ChĂȘne  <fabien.chene@gmail.com>
 
diff --git a/gcc/testsuite/g++.dg/template/sfinae18.C b/gcc/testsuite/g++.dg/template/sfinae18.C
new file mode 100644 (file)
index 0000000..bbc39cb
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/41468
+
+typedef int Ft(int);
+struct A { operator Ft*(); };
+struct B { operator Ft*(); };
+struct C : A, B { };
+
+template<typename C> void f(int (*a)[sizeof(C()(0))]);
+template<typename C> void f(...);
+int main() { f<C>(0); }