tree value; /* A (possibly ambiguous) set of things found. */
tree type; /* A type that has been found. */
LOOK_want want; /* What kind of entity we want. */
- bool hidden; /* Allow hidden */
bool deduping; /* Full deduping is needed because using declarations
are in play. */
static name_lookup *active;
public:
- name_lookup (tree n, LOOK_want w = LOOK_want::NORMAL, bool h = false)
+ name_lookup (tree n, LOOK_want w = LOOK_want::NORMAL)
: name (n), value (NULL_TREE), type (NULL_TREE),
- want (w), hidden (h),
+ want (w),
deduping (false), scopes (NULL), previous (NULL)
{
preserve_state ();
if (!deduping && TREE_CODE (fns) == OVERLOAD)
{
tree probe = fns;
- if (!hidden)
+ if (!bool (want & LOOK_want::HIDDEN_FRIEND))
probe = ovl_skip_hidden (probe);
if (probe && TREE_CODE (probe) == OVERLOAD
&& OVL_DEDUP_P (probe))
/* Did we really see a type? */
if (new_type
&& ((want & LOOK_want::TYPE_NAMESPACE) == LOOK_want::NAMESPACE
- || (!hidden
+ || (!bool (want & LOOK_want::HIDDEN_FRIEND)
&& DECL_LANG_SPECIFIC (new_type)
&& DECL_ANTICIPATED (new_type))))
new_type = NULL_TREE;
- if (new_val && !hidden)
+ if (new_val && !bool (want & LOOK_want::HIDDEN_FRIEND))
new_val = ovl_skip_hidden (new_val);
/* Do we really see a value? */
if (scope == global_namespace)
break;
- /* If looking for hidden names, we only look in the innermost
+ /* If looking for hidden friends, we only look in the innermost
namespace scope. [namespace.memdef]/3 If a friend
declaration in a non-local class first declares a class,
function, class template or function template the friend is a
member of the innermost enclosing namespace. See also
[basic.lookup.unqual]/7 */
- if (hidden)
+ if (bool (want & LOOK_want::HIDDEN_FRIEND))
break;
}
return REAL_IDENTIFIER_TYPE_VALUE (id);
/* Have to search for it. It must be on the global level, now.
Ask lookup_name not to return non-types. */
- id = lookup_name_real (id, LOOK_where::BLOCK_NAMESPACE, LOOK_want::TYPE, 0);
+ id = lookup_name_real (id, LOOK_where::BLOCK_NAMESPACE, LOOK_want::TYPE);
if (id)
return TREE_TYPE (id);
return NULL_TREE;
children. */
tree old = NULL_TREE;
{
- name_lookup lookup (DECL_NAME (decl), LOOK_want::NORMAL, true);
+ name_lookup lookup (DECL_NAME (decl),
+ LOOK_want::NORMAL | LOOK_want::HIDDEN_FRIEND);
if (!lookup.search_qualified (scope, /*usings=*/false))
/* No old declaration at all. */
goto not_found;
lookup_type_scope. */
static bool
-qualify_lookup (tree val, LOOK_want want, int flags)
+qualify_lookup (tree val, LOOK_want want)
{
if (val == NULL_TREE)
return false;
return false;
/* Look through lambda things that we shouldn't be able to see. */
- if (!(flags & LOOKUP_HIDDEN) && is_lambda_ignored_entity (val))
+ if (!bool (want & LOOK_want::HIDDEN_LAMBDA) && is_lambda_ignored_entity (val))
return false;
return true;
neither a class-type nor a namespace a diagnostic is issued. */
tree
-lookup_qualified_name (tree scope, tree name, LOOK_want want, bool complain,
- bool find_hidden /*=false*/)
+lookup_qualified_name (tree scope, tree name, LOOK_want want, bool complain)
{
tree t = NULL_TREE;
if (TREE_CODE (scope) == NAMESPACE_DECL)
{
- name_lookup lookup (name, want, find_hidden);
+ name_lookup lookup (name, want);
if (qualified_namespace_lookup (scope, &lookup))
t = lookup.value;
/* Wrapper for the above that takes a string argument. The function name is
not at the beginning of the line to keep this wrapper out of etags. */
-tree lookup_qualified_name (tree t, const char *p, LOOK_want w, bool c, bool fh)
+tree lookup_qualified_name (tree t, const char *p, LOOK_want w, bool c)
{
- return lookup_qualified_name (t, get_identifier (p), w, c, fh);
+ return lookup_qualified_name (t, get_identifier (p), w, c);
}
/* [namespace.qual]
namespace or type. */
static tree
-lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want, int flags)
+lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want)
{
tree val = NULL_TREE;
continue;
/* If this is the kind of thing we're looking for, we're done. */
- if (qualify_lookup (iter->value, want, flags))
+ if (qualify_lookup (iter->value, want))
binding = iter->value;
else if (bool (want & LOOK_want::TYPE)
- && qualify_lookup (iter->type, want, flags))
+ && qualify_lookup (iter->type, want))
binding = iter->type;
else
binding = NULL_TREE;
/* Now lookup in namespace scopes. */
if (!val && bool (where & LOOK_where::NAMESPACE))
{
- name_lookup lookup (name, want, flags & LOOKUP_HIDDEN);
+ name_lookup lookup (name, want);
if (lookup.search_unqualified
(current_decl_namespace (), current_binding_level))
val = lookup.value;
/* Wrapper for lookup_name_real_1. */
tree
-lookup_name_real (tree name, LOOK_where where, LOOK_want want, int flags)
+lookup_name_real (tree name, LOOK_where where, LOOK_want want)
{
- tree ret;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- ret = lookup_name_real_1 (name, where, want, flags);
+ tree ret = lookup_name_real_1 (name, where, want);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return ret;
}
tree
lookup_name_nonclass (tree name)
{
- return lookup_name_real (name, LOOK_where::BLOCK_NAMESPACE,
- LOOK_want::NORMAL, 0);
+ return lookup_name_real (name, LOOK_where::BLOCK_NAMESPACE, LOOK_want::NORMAL);
}
tree
lookup_name (tree name)
{
- return lookup_name_real (name, LOOK_where::ALL, LOOK_want::NORMAL, 0);
+ return lookup_name_real (name, LOOK_where::ALL, LOOK_want::NORMAL);
}
tree
lookup_name (tree name, LOOK_want want)
{
- return lookup_name_real (name, LOOK_where::ALL, want, 0);
+ return lookup_name_real (name, LOOK_where::ALL, want);
}
/* Look up NAME for type used in elaborated name specifier in
typedef struct C {} C;
correctly. */
if (tree type = iter->type)
- if (qualify_lookup (type, LOOK_want::TYPE, false)
+ if (qualify_lookup (type, LOOK_want::TYPE)
&& (scope != ts_current
|| LOCAL_BINDING_P (iter)
|| DECL_CONTEXT (type) == iter->scope->this_entity))
return type;
- if (qualify_lookup (iter->value, LOOK_want::TYPE, false)
+ if (qualify_lookup (iter->value, LOOK_want::TYPE)
&& (scope != ts_current
|| !INHERITED_VALUE_BINDING_P (iter)))
return iter->value;
{
/* If this is the kind of thing we're looking for, we're done. */
if (tree type = MAYBE_STAT_TYPE (*slot))
- if (qualify_lookup (type, LOOK_want::TYPE, false))
+ if (qualify_lookup (type, LOOK_want::TYPE))
return type;
if (tree decl = MAYBE_STAT_DECL (*slot))
- if (qualify_lookup (decl, LOOK_want::TYPE, false))
+ if (qualify_lookup (decl, LOOK_want::TYPE))
return decl;
}
TYPE = 1 << 1, /* We only want TYPE_DECLS. */
NAMESPACE = 1 << 2, /* We only want NAMESPACE_DECLS. */
+ HIDDEN_FRIEND = 1 << 3, /* See hidden friends. */
+ HIDDEN_LAMBDA = 1 << 4, /* See lambda-ignored entities. */
+
TYPE_NAMESPACE = TYPE | NAMESPACE, /* Either NAMESPACE or TYPE. */
};
constexpr LOOK_want operator| (LOOK_want a, LOOK_want b)
return LOOK_want (unsigned (a) & unsigned (b));
}
-extern tree lookup_name_real (tree, LOOK_where, LOOK_want, int flags);
+extern tree lookup_name_real (tree, LOOK_where, LOOK_want);
extern tree lookup_type_scope (tree, tag_scope);
extern tree get_namespace_binding (tree ns, tree id);
extern void set_global_binding (tree decl);
extern tree lookup_name (tree name, LOOK_want);
extern tree lookup_qualified_name (tree scope, tree name,
LOOK_want = LOOK_want::NORMAL,
- bool = true, /*hidden*/bool = false);
+ bool = true);
extern tree lookup_qualified_name (tree scope, const char *name,
LOOK_want = LOOK_want::NORMAL,
- bool = true, bool = false);
+ bool = true);
extern tree lookup_name_nonclass (tree);
extern bool is_local_extern (tree);
extern bool pushdecl_class_level (tree);
if (fns == error_mark_node)
/* If lookup fails, look for a friend declaration so we can
give a better diagnostic. */
- fns = lookup_qualified_name (CP_DECL_CONTEXT (decl), dname,
- LOOK_want::NORMAL, /*complain*/true,
- /*hidden*/true);
+ fns = (lookup_qualified_name
+ (CP_DECL_CONTEXT (decl), dname,
+ LOOK_want::NORMAL | LOOK_want::HIDDEN_FRIEND,
+ /*complain*/true));
if (fns == error_mark_node || !is_overloaded_fn (fns))
{
}
tmpl = lookup_name_real (DECL_NAME (friend_tmpl), LOOK_where::CLASS_NAMESPACE,
- LOOK_want::NORMAL, LOOKUP_HIDDEN);
+ LOOK_want::NORMAL | LOOK_want::HIDDEN_FRIEND);
if (tmpl && DECL_CLASS_TEMPLATE_P (tmpl))
{
for (int i = 0; i < len; ++i)
{
tree ename = vec ? make_ith_pack_parameter_name (cname, i) : cname;
- tree elt = lookup_name_real (ename, LOOK_where::ALL, LOOK_want::NORMAL,
- LOOKUP_NORMAL);
+ tree elt = lookup_name_real (ename, LOOK_where::ALL, LOOK_want::NORMAL);
if (vec)
TREE_VEC_ELT (vec, i) = elt;
else
tree inst;
if (!DECL_PACK_P (decl))
{
- inst = lookup_name_real (DECL_NAME (decl),
- LOOK_where::BLOCK_NAMESPACE,
- LOOK_want::NORMAL,
- LOOKUP_HIDDEN);
+ inst = (lookup_name_real
+ (DECL_NAME (decl), LOOK_where::BLOCK,
+ LOOK_want::NORMAL | LOOK_want::HIDDEN_LAMBDA));
gcc_assert (inst != decl && is_capture_proxy (inst));
}
else if (is_normal_capture_proxy (decl))
{
guides = lookup_qualified_name (CP_DECL_CONTEXT (tmpl),
dguide_name (tmpl),
- LOOK_want::NORMAL, /*complain*/false,
- /*hidden*/false);
+ LOOK_want::NORMAL, /*complain*/false);
if (guides == error_mark_node)
guides = NULL_TREE;
}