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 87d666e4930b486e3c3cfaca823013b853ff4b92..9fa2f3a87d50a46f81d177def28b625d12090075 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 889852f362b7a532a743ca960e5ec25fd7d9b8ca..f929fb2042d86e1a873c6760effd0d11dc7d442d 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 ff3e335735359a57da09ea73d4bb1e8aaba5c35a..86655a043d7bb412ea2ecee031b201a0af9e268c 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" }
+}