re PR c++/71835 (ICE on invalid C++ code with ambiguous overloaded operators: tree...
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Jul 2016 18:44:51 +0000 (20:44 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Jul 2016 18:44:51 +0000 (20:44 +0200)
PR c++/71835
* call.c (build_op_call_1): Use convert_like_with_context only
if cand->fn is a decl.

* g++.dg/conversion/ambig3.C: New test.

From-SVN: r238443

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

index 87d666e..9fa2f3a 100644 (file)
@@ -1,5 +1,9 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71835
+       * call.c (build_op_call_1): Use convert_like_with_context only
+       if cand->fn is a decl.
+
        PR c++/71828
        * constexpr.c (cxx_eval_constant_expression) <case REALPART_EXPR>:
        For lval don't use cxx_eval_unary_expression and instead recurse
index 889852f..f929fb2 100644 (file)
@@ -4412,8 +4412,11 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
        result = build_over_call (cand, LOOKUP_NORMAL, complain);
       else
        {
-         obj = convert_like_with_context (cand->convs[0], obj, cand->fn, -1,
-                                          complain);
+         if (DECL_P (cand->fn))
+           obj = convert_like_with_context (cand->convs[0], obj, cand->fn,
+                                            -1, complain);
+         else
+           obj = convert_like (cand->convs[0], obj, complain);
          obj = convert_from_reference (obj);
          result = cp_build_function_call_vec (obj, args, complain);
        }
index ff3e335..86655a0 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71835
+       * g++.dg/conversion/ambig3.C: New test.
+
        PR c++/71828
        * g++.dg/cpp0x/constexpr-71828.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/conversion/ambig3.C b/gcc/testsuite/g++.dg/conversion/ambig3.C
new file mode 100644 (file)
index 0000000..e17b64e
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/71835
+// { dg-do compile }
+
+typedef void T (int);
+struct A { operator T * (); }; // { dg-message "candidate" }
+struct B { operator T * (); }; // { dg-message "candidate" }
+struct C : A, B {} c;
+
+void
+foo ()
+{
+  c (0);               // { dg-error "is ambiguous" }
+}