c++: Yet more name-lookup api simplification

Nathan Sidwell nathan@acm.org
Fri Aug 14 17:56:50 GMT 2020

This patch deals with LOOKUP_HIDDEN, which originally meant 'find hidden 
friends', but it's being pressed into service for not ignoring 
lambda-relevant internals.  However these two functions are different. 
(a) hidden friends can occur in block scope (very uncommon) and (b) it
had the semantics of stopping after the innermost enclosing namepspace. 
That's really suspect for the lambda case, but not relevant there 
because we never get to namespace scope (I think). Anyway, I've split 
the flag into two and adjusted the lambda callers to just search block 
scope.  These two flags are added to the LOOK_want enum class, which 
allows dropping another parameter from the name lookup routines.

The remaining LOOKUP_$FOO flags in cp-tree.h are, I think, now all 
related to features of overload resolution, conversion operators and 
reference binding.  Nothing to do with /name/ lookup.


         * cp-tree.h (LOOKUP_HIDDEN): Delete.
         (LOOKUP_PREFER_RVALUE): Adjust initializer.
         * name-lookup.h (enum class LOOK_want): Add HIDDEN_FRIEND and
         HIDDEN_LAMBDA flags.
         (lookup_name_real): Drop flags parm.
         (lookup_qualified_name): Drop find_hidden parm.
         * name-lookup.c (class name_lookup): Drop hidden field, adjust
         (name_lookup::add_overload): Check want for hiddenness.
         (name_lookup::process_binding): Likewise.
         (name_lookup::search_unqualified): Likewise.
         (identifier_type_value_1): Adjust lookup_name_real call.
         (set_decl_namespace): Adjust name_lookup ctor.
         (qualify_lookup): Drop flags parm, use want for hiddenness.
         (lookup_qualified_name): Drop find_hidden parm.
         (lookup_name_real_1): Drop flags parm, adjust qualify_lookup
         (lookup_name_real): Drop flags parm.
         (lookup_name_nonclass, lookup_name): Adjust lookup_name_real
         (lookup_type_scope_1): Adjust qualify_lookup calls.
         * call.c (build_operator_new_call): Adjust lookup_name_real call.
         (add_operator_candidates): Likewise.
         * coroutines.cc (morph_fn_to_coro): Adjust lookup_qualified_name
         * parser.c (cp_parser_lookup_name): Adjust lookup_name_real calls.
         * pt.c (check_explicit_specialization): Adjust
         lookup_qualified_name call.
         (deduction_guides_for): Likewise.
         (tsubst_friend_class): Adjust lookup_name_real call.
         (lookup_init_capture_pack): Likewise.
         (tsubst_expr): Likewise, don't look in namespaces.
         * semantics.c (capture_decltype): Adjust lookup_name_real.  Don't
         look in namespaces.
         * libcp1plugin.cc (plugin_build_dependent_exp): Adjust
         lookup_name_real call.

Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: name-lookup-api-3.diff
Type: text/x-patch
Size: 16975 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200814/e297ff33/attachment.bin>

More information about the Gcc-patches mailing list