#include "debug.h"
#include "c-family/c-pragma.h"
#include "params.h"
+#include "pointer-set.h"
/* The bindings for a particular name in a particular scope. */
VEC(tree,gc) *namespaces;
VEC(tree,gc) *classes;
tree functions;
+ struct pointer_set_t *fn_set;
};
static bool arg_assoc (struct arg_lookup*, tree);
static bool
add_function (struct arg_lookup *k, tree fn)
{
- /* We used to check here to see if the function was already in the list,
- but that's O(n^2), which is just too expensive for function lookup.
- Now we deal with the occasional duplicate in joust. In doing this, we
- assume that the number of duplicates will be small compared to the
- total number of functions being compared, which should usually be the
- case. */
-
if (!is_overloaded_fn (fn))
/* All names except those of (possibly overloaded) functions and
function templates are ignored. */;
+ else if (k->fn_set && pointer_set_insert (k->fn_set, fn))
+ /* It's already in the list. */;
else if (!k->functions)
k->functions = fn;
else if (fn == k->functions)
picking up later definitions) in the second stage. */
k.namespaces = make_tree_vector ();
+ /* We used to allow duplicates and let joust discard them, but
+ since the above change for DR 164 we end up with duplicates of
+ all the functions found by unqualified lookup. So keep track
+ of which ones we've seen. */
+ if (fns)
+ {
+ tree ovl;
+ /* We shouldn't be here if lookup found something other than
+ namespace-scope functions. */
+ gcc_assert (DECL_NAMESPACE_SCOPE_P (OVL_CURRENT (fns)));
+ k.fn_set = pointer_set_create ();
+ for (ovl = fns; ovl; ovl = OVL_NEXT (ovl))
+ pointer_set_insert (k.fn_set, OVL_CURRENT (ovl));
+ }
+ else
+ k.fn_set = NULL;
+
if (include_std)
arg_assoc_namespace (&k, std_node);
arg_assoc_args_vec (&k, args);
release_tree_vector (k.classes);
release_tree_vector (k.namespaces);
+ if (k.fn_set)
+ pointer_set_destroy (k.fn_set);
return fns;
}
// Bug: g++ was crashing after giving errors.
template<class T>
- void connect_to_method( // { dg-message "connect_to_method|no known conversion" }
+ void connect_to_method(
T *receiver,
void (T::*method)())
{}
Gtk_Base::Gtk_Base()
{
- connect_to_method(this,&show); // { dg-error "no match" } invalid pmf expression
- // { dg-message "candidate" "candidate note" { target *-*-* } 23 }
+ connect_to_method(this,&show); // { dg-error "pointer to member" } invalid pmf expression
connect_to_method(this,&expose); // { dg-error "pointer to member" } invalid pmf expression
}