From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 61F703858D20; Tue, 15 Mar 2022 12:51:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61F703858D20 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base Date: Tue, 15 Mar 2022 12:51:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2022 12:51:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103177 --- Comment #2 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:ffe9c0a0d3564a6083ea6194eb3374a89c29c085 commit r12-7656-gffe9c0a0d3564a6083ea6194eb3374a89c29c085 Author: Patrick Palka Date: Tue Mar 15 08:50:24 2022 -0400 c++: extraneous access error with ambiguous lookup [PR103177] When a lookup is ambiguous, lookup_member still attempts to check access of the first member found before diagnosing the ambiguity and propagating the error, and this may cause us to issue an extraneous access error as in the testcase below (for B1::foo). This patch fixes this by swapping the order of the ambiguity and access checks within lookup_member. In passing, since the only thing that cou= ld go wrong during lookup_field_r is ambiguity, we might as well hardcode that in lookup_member and get rid of lookup_field_info::errstr. PR c++/103177 gcc/cp/ChangeLog: * search.cc (lookup_field_info::errstr): Remove this data member. (lookup_field_r): Don't set errstr. (lookup_member): Check ambiguity before checking access. Simplify accordingly after errstr removal. Exit early upon error or empty result. gcc/testsuite/ChangeLog: * g++.dg/lookup/ambig6.C: New test.=