diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 87d666e4930..9fa2f3a87d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-07-18 Jakub Jelinek + 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) : For lval don't use cxx_eval_unary_expression and instead recurse diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 889852f362b..f929fb2042d 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4412,8 +4412,11 @@ build_op_call_1 (tree obj, vec **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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff3e3357353..86655a043d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-07-18 Jakub Jelinek + 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 index 00000000000..e17b64ea90a --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ambig3.C @@ -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" } +}