diff options
author | Jason Merrill <jason@redhat.com> | 2010-05-12 13:34:28 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-05-12 13:34:28 -0400 |
commit | 404f08f8d52a28a0590e858c339c68ca7f78ccfd (patch) | |
tree | 6f028aa195e1257bca4a73bcbc7579f2af2613ab /gcc/cp/call.c | |
parent | 5c824000a5b855d454483bee7d32850f161ecdab (diff) | |
download | gcc-404f08f8d52a28a0590e858c339c68ca7f78ccfd.zip gcc-404f08f8d52a28a0590e858c339c68ca7f78ccfd.tar.gz gcc-404f08f8d52a28a0590e858c339c68ca7f78ccfd.tar.bz2 |
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
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 15 |
1 files changed, 14 insertions, 1 deletions
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; |