aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index fab01fc..e8f93c4 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1309,10 +1309,10 @@ add_function_candidate (struct z_candidate **candidates,
tree orig_arglist;
int viable = 1;
- /* Built-in functions that haven't been declared don't really
- exist. */
- if (DECL_ANTICIPATED (fn))
- return NULL;
+ /* At this point we should not see any functions which haven't been
+ explicitly declared, except for friend functions which will have
+ been found using argument dependent lookup. */
+ gcc_assert (!DECL_ANTICIPATED (fn) || DECL_HIDDEN_FRIEND_P (fn));
/* The `this', `in_chrg' and VTT arguments to constructors are not
considered in overload resolution. */
@@ -2758,7 +2758,7 @@ perform_overload_resolution (tree fn,
or a static member function) with the ARGS. */
tree
-build_new_function_call (tree fn, tree args)
+build_new_function_call (tree fn, tree args, bool koenig_p)
{
struct z_candidate *candidates, *cand;
bool any_viable_p;
@@ -2769,6 +2769,22 @@ build_new_function_call (tree fn, tree args)
if (args == error_mark_node)
return error_mark_node;
+ /* If this function was found without using argument dependent
+ lookup, then we want to ignore any undeclared friend
+ functions. */
+ if (!koenig_p)
+ {
+ tree orig_fn = fn;
+
+ fn = remove_hidden_names (fn);
+ if (!fn)
+ {
+ error ("no matching function for call to %<%D(%A)%>",
+ DECL_NAME (OVL_CURRENT (orig_fn)), args);
+ return error_mark_node;
+ }
+ }
+
/* Get the high-water mark for the CONVERSION_OBSTACK. */
p = conversion_obstack_alloc (0);