PR c++/77563 - missing ambiguous conversion error.
authorJason Merrill <jason@redhat.com>
Thu, 23 Mar 2017 12:50:55 +0000 (08:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Mar 2017 12:50:55 +0000 (08:50 -0400)
* call.c (convert_like_real): Use LOOKUP_IMPLICIT.

From-SVN: r246417

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

index 98560b053f1e3f15905631ab028c523faf94a0c5..22b7dfae028507d2e3579dafdf2a953c08db62fd 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/77563 - missing ambiguous conversion error.
+       * call.c (convert_like_real): Use LOOKUP_IMPLICIT.
+
 2017-03-23  Marek Polacek  <polacek@redhat.com>
 
        * cp-tree.h: Remove a C_RID_YYCODE reference.
index 86c7647e7cd75e5c2f0412a0cea413de8dff7996..803fbd4197e9ab1b030717d2a3505cf1690106dc 100644 (file)
@@ -6764,7 +6764,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
       if (complain & tf_error)
        {
          /* Call build_user_type_conversion again for the error.  */
-         build_user_type_conversion (totype, convs->u.expr, LOOKUP_NORMAL,
+         build_user_type_conversion (totype, convs->u.expr, LOOKUP_IMPLICIT,
                                      complain);
          if (fn)
            inform (DECL_SOURCE_LOCATION (fn),
diff --git a/gcc/testsuite/g++.dg/overload/ambig3.C b/gcc/testsuite/g++.dg/overload/ambig3.C
new file mode 100644 (file)
index 0000000..01d4cc6
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/77563
+
+struct A {
+  A(int) {}
+  A(unsigned) {}  // Comment to make it work
+
+  explicit A(long) {}  // Comment to make it work
+};
+
+void f(A) { }
+
+int main() {
+  f(2);
+  f(3l);                       // { dg-error "ambiguous" }
+}