public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-107773-4-DdcB47OSJj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107773-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107773

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:46711ff8e60d64b7e5550f4614c29d42b224f98b

commit r13-6098-g46711ff8e60d64b7e5550f4614c29d42b224f98b
Author: Patrick Palka <ppalka@redhat.com>
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=true
            instead of =false to lookup_member.  Generalize format specifier
            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) <case USING_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.
            <case TYPENAME_TYPE>: 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.
            <case SCOPE_REF>: Set tf_qualifying_scope when substituting the
            scope.
            <case *_TYPE>: 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.

  parent reply	other threads:[~2023-02-16 16:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 19:28 [Bug c++/107773] New: Class members do not hide nested types eiband at mail dot de
2022-11-20 19:47 ` [Bug c++/107773] " pinskia at gcc dot gnu.org
2022-11-28 16:41 ` [Bug c++/107773] Class members do not hide inherited types inside requires ppalka at gcc dot gnu.org
2022-11-28 21:00 ` ppalka at gcc dot gnu.org
2023-02-16 16:12 ` cvs-commit at gcc dot gnu.org [this message]
2023-02-16 16:27 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107773-4-DdcB47OSJj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).