From 404f08f8d52a28a0590e858c339c68ca7f78ccfd Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 12 May 2010 13:34:28 -0400 Subject: call.c (add_candidates): Distinguish between type(x) and x.operator type(). * call.c (add_candidates): Distinguish between type(x) and x.operator type(). (convert_class_to_reference): Set LOOKUP_NO_CONVERSION. (build_new_method_call): Give better error for conversion op. From-SVN: r159333 --- gcc/cp/call.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'gcc/cp/call.c') diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 17ad99e..204a6bb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1053,6 +1053,10 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags) t = TREE_TYPE (reference_type); + /* We're performing a user-defined conversion to a desired type, so set + this for the benefit of add_candidates. */ + flags |= LOOKUP_NO_CONVERSION; + for (; conversions; conversions = TREE_CHAIN (conversions)) { tree fns = TREE_VALUE (conversions); @@ -4017,7 +4021,12 @@ add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args, if (DECL_CONV_FN_P (fn)) { check_converting = !!(flags & LOOKUP_ONLYCONVERTING); - strict = DEDUCE_CONV; + if (flags & LOOKUP_NO_CONVERSION) + /* We're doing return_type(x). */ + strict = DEDUCE_CONV; + else + /* We're doing x.operator return_type(). */ + strict = DEDUCE_EXACT; /* [over.match.funcs] For conversion functions, the function is considered to be a member of the class of the implicit object argument for the purpose of defining the type of @@ -6318,6 +6327,10 @@ build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args, { if (!COMPLETE_TYPE_P (basetype)) cxx_incomplete_type_error (instance_ptr, basetype); + else if (optype) + error ("no matching function for call to %<%T::operator %T(%A)%#V%>", + basetype, optype, build_tree_list_vec (user_args), + TREE_TYPE (TREE_TYPE (instance_ptr))); else { char *pretty_name; -- cgit v1.1