From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CA09F385B52A; Thu, 30 Mar 2023 22:26:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA09F385B52A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680215172; bh=wVfKvqv02jECJVhHATAsdgRx5swP4nujgIfUwgVq6Wk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ShbgifCRCo+p2b0afbZ9nIYH1re0YypwI0yMbIV43PhNOhvY3XUrJaYA+jHFQEAAE nBH2LEQEwEX2iAmY4RKKppCrS7D4hgpEWQf5YtrGBu1zVewnbp6qbRhE6asA6QXjbV Ar5X2szA8/TrLtH15zAamdAH5HozaGvu3NZT4Bjk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105452] [10/11/12/13 Regression] static_assert inside anonymous union inside a templated struct causes invalid "inaccessible within this context" error Date: Thu, 30 Mar 2023 22:26:12 +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: 13.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105452 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:58df5350753c00f140c86e60ba5ce0cac686ec4b commit r13-6949-g58df5350753c00f140c86e60ba5ce0cac686ec4b Author: Jason Merrill Date: Wed Mar 29 23:27:38 2023 -0400 c++: anonymous union member reference [PR105452] While parsing the anonymous union, we don't yet know that it's an anony= mous union, so we build the reference to 'v' in the static_assert relative to the union type. But at instantiation time we know it's an anonymous union,= so we need to avoid trying to check access for 'v' in the union again; the simplest approach seemed to be to make accessible_p step out to the containing class. While looking at this I also noticed that we were having trouble with D= MI in an anonymous union referring to members of the containing class; there we just need to give current_class_ptr the right type. PR c++/105452 gcc/cp/ChangeLog: * search.cc (type_context_for_name_lookup): New. (accessible_p): Handle anonymous union. * init.cc (maybe_instantiate_nsdmi_init): Use type_context_for_name_lookup. * parser.cc (cp_parser_class_specifier): Likewise. * cp-tree.h (type_context_for_name_lookup): Declare. gcc/testsuite/ChangeLog: * g++.dg/lookup/anon8.C: New test.=