From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DCC7B3858296; Thu, 16 Feb 2023 16:12:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCC7B3858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676563949; bh=Ct4S6gygRfKUrvwVH9kDh0PDrkBSn4b43XWHXEFpYgo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sSTr5ZrLRKN+VqdVubZUi6by5TNjixWkqGlHxR8/D/rvZOibe+WBg67ErF5/wDvB1 SFop772j7jo//iI5YcaEM24pqBsVuRB7n3Ja3Cakw0JgPW2fz1pGYcpUr+nA5uQOjk rJwU5AGwOL0LnHJiNrVud8LUfwBXxn/JEtVT3b48= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107773] Class members do not hide inherited types inside requires Date: Thu, 16 Feb 2023 16:12:29 +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.1.0 X-Bugzilla-Keywords: accepts-invalid, rejects-valid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107773 --- Comment #3 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:46711ff8e60d64b7e5550f4614c29d42b224f98b commit r13-6098-g46711ff8e60d64b7e5550f4614c29d42b224f98b Author: Patrick Palka Date: Thu Feb 16 11:12:19 2023 -0500 c++: TYPENAME_TYPE lookup ignoring non-types [PR107773] Currently when resolving a TYPENAME_TYPE for 'typename T::m' via make_typename_type, we consider only type bindings of 'm' and ignore non-type ones. But [temp.res.general]/3 says, in a note, "the usual qualified name lookup ([basic.lookup.qual]) applies even in the presence of 'typename'", and qualified name lookup doesn't discriminate between type and non-type bindings. So when resolving such a TYPENAME_TYPE we want the lookup to consider all bindings. An exception is when we have a TYPENAME_TYPE corresponding to the qualifying scope of the :: scope resolution operator, such as 'T::type' in 'T::type::m'. In that case, [basic.lookup.qual]/1 applies, and lookup for such a TYPENAME_TYPE must ignore non-type bindings. So in order to correctly handle all cases, make_typename_type needs an additional flag controlling whether to restrict the lookup. To that end this patch adds a new tsubst flag tf_qualifying_scope denoting whether we're substituting the LHS of the :: operator, which make_typename_type will look for to conditionally restrict the lookup to type bindings (by default we want to consider all bindings). So in contexts such as substituting into the scope of TYPENAME_TYPE, SCOPE_REF or USING_DECL we simply pass tf_qualifying_scope to the relevant tsubst / tsubst_copy call, and if that scope is a TYPENAME_TYPE then make_typename_type will restrict the lookup accordingly. This flag is intended to apply only to overall scope (TYPENAME_TYPE or not) so we must be careful to clear the flag to avoid propagating it when recursing into sub-trees of the scope. PR c++/107773 gcc/cp/ChangeLog: * cp-tree.h (enum tsubst_flags): New flag tf_qualifying_scope. * decl.cc (make_typename_type): Use lookup_member instead of lookup_field. If tf_qualifying_scope is set, pass want_type=3D= true instead of =3Dfalse to lookup_member. Generalize format specif= ier in diagnostic to handle both type and non-type bindings. * pt.cc (tsubst_aggr_type_1): Clear tf_qualifying_scope. Tidy the function. (tsubst_decl) : Set tf_qualifying_scope when substituting USING_DECL_SCOPE. (tsubst): Clear tf_qualifying_scope right away and remember if it was set. Do the same for tf_tst_ok sooner. : Set tf_qualifying_scope when substituting TYPE_CONTEXT. Pass tf_qualifying_scope to make_typename_type if it was set. (tsubst_qualified_id): Set tf_qualifying_scope when substituting the scope. (tsubst_copy): Clear tf_qualifying_scope and remember if it was set. : Set tf_qualifying_scope when substituting the scope. : Pass tf_qualifying_scope to tsubst if it was set. * search.cc (lookup_member): Document default argument. gcc/testsuite/ChangeLog: * g++.dg/template/typename24.C: New test. * g++.dg/template/typename25.C: New test. * g++.dg/template/typename25a.C: New test. * g++.dg/template/typename26.C: New test.=