public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7784] c++: using from enclosing class template [PR105006]
Date: Wed, 23 Mar 2022 12:56:33 +0000 (GMT)	[thread overview]
Message-ID: <20220323125633.222243864C65@sourceware.org> (raw)

https://gcc.gnu.org/g:a3f78748fab6b24e3d4a8b319afd3f8afa17248f

commit r12-7784-ga3f78748fab6b24e3d4a8b319afd3f8afa17248f
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 22 11:17:26 2022 -0400

    c++: using from enclosing class template [PR105006]
    
    Here, DECL_DEPENDENT_P was false for the second using because Row<eT> is
    "the current instantiation", so lookup succeeds.  But since Row itself has a
    dependent using-decl for operator(), the set of functions imported by the
    second using is dependent, so we should set the flag.
    
            PR c++/105006
    
    gcc/cp/ChangeLog:
    
            * name-lookup.cc (lookup_using_decl): Set DECL_DEPENDENT_P if lookup
            finds a dependent using.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/template/using30.C: New test.

Diff:
---
 gcc/cp/name-lookup.cc                   | 15 +++++++++++++++
 gcc/testsuite/g++.dg/template/using30.C | 13 +++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 323f96bcd24..ea947fabb7e 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -5665,6 +5665,21 @@ lookup_using_decl (tree scope, name_lookup &lookup)
 	lookup.value = lookup_member (binfo, lookup.name, /*protect=*/2,
 				      /*want_type=*/false, tf_none);
 
+      /* If the lookup in the base contains a dependent using, this
+	 using is also dependent.  */
+      if (!dependent_p && lookup.value)
+	{
+	  tree val = lookup.value;
+	  if (tree fns = maybe_get_fns (val))
+	    val = fns;
+	  for (tree f: lkp_range (val))
+	    if (TREE_CODE (f) == USING_DECL && DECL_DEPENDENT_P (f))
+	      {
+		dependent_p = true;
+		break;
+	      }
+	}
+
       if (!depscope && b_kind < bk_proper_base)
 	{
 	  if (cxx_dialect >= cxx20 && lookup.value
diff --git a/gcc/testsuite/g++.dg/template/using30.C b/gcc/testsuite/g++.dg/template/using30.C
new file mode 100644
index 00000000000..914252dd14c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/using30.C
@@ -0,0 +1,13 @@
+// PR c++/105006
+
+template<class eT>
+class Row {
+  using eT::operator();
+  void operator()();
+  class fixed;
+};
+
+template<class eT>
+class Row<eT>::fixed : Row {
+  using Row::operator();
+};


                 reply	other threads:[~2022-03-23 12:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220323125633.222243864C65@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@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).