From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 6617D385F00F; Wed, 16 Mar 2022 12:26:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6617D385F00F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7669] c++: further lookup_member simplification X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: e55c5e24b97ad8ddc44588da18e894c139e02c0a X-Git-Newrev: 5809bb4f78c9aae0f3be3c8d942b6af75ba23a74 Message-Id: <20220316122659.6617D385F00F@sourceware.org> Date: Wed, 16 Mar 2022 12:26:59 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Mar 2022 12:26:59 -0000 https://gcc.gnu.org/g:5809bb4f78c9aae0f3be3c8d942b6af75ba23a74 commit r12-7669-g5809bb4f78c9aae0f3be3c8d942b6af75ba23a74 Author: Patrick Palka Date: Wed Mar 16 08:26:11 2022 -0400 c++: further lookup_member simplification As a minor followup to r12-7656-gffe9c0a0d3564a, this condenses the handling of ambiguity and access w.r.t. the value of 'protect' so that the logic is more clear. gcc/cp/ChangeLog: * search.cc (lookup_member): Simplify by handling all values of protect together in the ambiguous case. Don't modify protect. Diff: --- gcc/cp/search.cc | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index 85e3e7cb487..b86b3a24080 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1168,27 +1168,21 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, if (rval_binfo) type = BINFO_TYPE (rval_binfo); - /* If we are not interested in ambiguities, don't report them; - just return NULL_TREE. */ - if (!protect && lfi.ambiguous) - return NULL_TREE; - - if (protect == 2) - { - if (lfi.ambiguous) - return lfi.ambiguous; - else - protect = 0; - } - - if (protect == 1 && lfi.ambiguous) + if (lfi.ambiguous) { - if (complain & tf_error) + if (protect == 0) + return NULL_TREE; + else if (protect == 1) { - error ("request for member %qD is ambiguous", name); - print_candidates (lfi.ambiguous); + if (complain & tf_error) + { + error ("request for member %qD is ambiguous", name); + print_candidates (lfi.ambiguous); + } + return error_mark_node; } - return error_mark_node; + else if (protect == 2) + return lfi.ambiguous; } if (!rval) @@ -1213,7 +1207,7 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, only the first call to "f" is valid. However, if the function is static, we can check. */ - if (protect && !really_overloaded_fn (rval)) + if (protect == 1 && !really_overloaded_fn (rval)) { tree decl = is_overloaded_fn (rval) ? get_first_fn (rval) : rval; decl = strip_using_decl (decl);