From 634046d1a81b48a48b3564ff2f90974f6b7b087b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 18 Aug 2020 06:02:37 -0700 Subject: [PATCH] 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. --- gcc/cp/name-lookup.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index ad9c92d..c68ea09 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)) -- 2.7.4