diff options
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r-- | gcc/cp/name-lookup.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 51de6fb..4753dc5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -165,7 +165,6 @@ public: 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. */ @@ -179,9 +178,9 @@ protected: 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 (); @@ -420,7 +419,7 @@ name_lookup::add_overload (tree fns) 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)) @@ -489,12 +488,12 @@ name_lookup::process_binding (tree new_val, tree new_type) /* 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? */ @@ -718,13 +717,13 @@ name_lookup::search_unqualified (tree scope, cp_binding_level *level) 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; } @@ -3744,7 +3743,7 @@ identifier_type_value_1 (tree id) 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; @@ -4818,7 +4817,8 @@ set_decl_namespace (tree decl, tree scope, bool friendp) 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; @@ -5217,7 +5217,7 @@ cp_namespace_decls (tree ns) 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; @@ -5238,7 +5238,7 @@ qualify_lookup (tree val, LOOK_want want, int flags) 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; @@ -5995,14 +5995,13 @@ suggest_alternative_in_scoped_enum (tree name, tree scoped_enum) 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; @@ -6021,9 +6020,9 @@ lookup_qualified_name (tree scope, tree name, LOOK_want want, bool complain, /* 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] @@ -6424,7 +6423,7 @@ innermost_non_namespace_value (tree name) 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; @@ -6480,10 +6479,10 @@ lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want, int flags) 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; @@ -6548,7 +6547,7 @@ lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want, int flags) /* 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; @@ -6564,11 +6563,10 @@ lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want, int flags) /* 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; } @@ -6576,20 +6574,19 @@ lookup_name_real (tree name, LOOK_where where, LOOK_want want, int flags) 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 @@ -6637,13 +6634,13 @@ lookup_type_scope_1 (tree name, tag_scope scope) 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; @@ -6664,11 +6661,11 @@ lookup_type_scope_1 (tree name, tag_scope scope) { /* 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; } |