diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-08-18 06:02:37 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-08-18 06:05:04 -0700 |
commit | 634046d1a81b48a48b3564ff2f90974f6b7b087b (patch) | |
tree | f3518da97e26a659ed3893fb324853a451d13a97 | |
parent | 6bebbc033d8bf2246745ffef7186b0424e08ba6b (diff) |
c++: Move hidden-lambda entity lookup checking
Hidden lambda entities only occur in block and class scopes. There's
no need to check for them on every lookup. So moving that particular
piece of validation to lookup_name_1, which cares. Also reordered the
namespace and type checking, as that is also simpler.
gcc/cp/
* name-lookup.c (qualify_lookup): Drop lambda checking here.
Reorder namespace & type checking.
(lookup_name_1): Do hidden lambda checking here.
-rw-r--r-- | gcc/cp/name-lookup.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index ad9c92da254..c68ea09e610 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5221,24 +5221,16 @@ qualify_lookup (tree val, LOOK_want want) if (val == NULL_TREE) return false; - if (bool (want & LOOK_want::NAMESPACE) && TREE_CODE (val) == NAMESPACE_DECL) - return true; - if (bool (want & LOOK_want::TYPE)) { tree target_val = strip_using_decl (val); - if (TREE_CODE (target_val) == TYPE_DECL - || TREE_CODE (target_val) == TEMPLATE_DECL) + if (TREE_CODE (STRIP_TEMPLATE (target_val)) == TYPE_DECL) return true; } if (bool (want & LOOK_want::TYPE_NAMESPACE)) - return false; - - /* Look through lambda things that we shouldn't be able to see. */ - if (!bool (want & LOOK_want::HIDDEN_LAMBDA) && is_lambda_ignored_entity (val)) - return false; + return TREE_CODE (val) == NAMESPACE_DECL; return true; } @@ -6430,7 +6422,10 @@ lookup_name_1 (tree name, LOOK_where where, LOOK_want want) tree val = NULL_TREE; gcc_checking_assert (unsigned (where) != 0); - + /* If we're looking for hidden lambda things, we shouldn't be + looking in namespace scope. */ + gcc_checking_assert (!bool (want & LOOK_want::HIDDEN_LAMBDA) + || !bool (where & LOOK_where::NAMESPACE)); query_oracle (name); /* Conversion operators are handled specially because ordinary @@ -6481,7 +6476,10 @@ lookup_name_1 (tree name, LOOK_where where, LOOK_want want) continue; /* If this is the kind of thing we're looking for, we're done. */ - if (qualify_lookup (iter->value, want)) + if (iter->value + && (bool (want & LOOK_want::HIDDEN_LAMBDA) + || !is_lambda_ignored_entity (iter->value)) + && qualify_lookup (iter->value, want)) binding = iter->value; else if (bool (want & LOOK_want::TYPE) && qualify_lookup (iter->type, want)) |