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 r10-9849] c++: using overloaded with local decl [PR92918]
Date: Thu, 20 May 2021 21:35:25 +0000 (GMT)	[thread overview]
Message-ID: <20210520213525.903343987C20@sourceware.org> (raw)

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

commit r10-9849-gdecd38f99dd05eb54ddcaee7c52f21a56a844613
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 7 14:55:48 2021 -0400

    c++: using overloaded with local decl [PR92918]
    
    The problem here was that the lookup for 'impl' when parsing the template
    only found the using-declaration, not the member function declaration.
    
    This happened because when trying to add the member function declaration,
    push_class_level_binding_1 saw that the current binding was a USING_DECL and
    the new value is an overload, and decided to just return success.
    
    That 'return true' dates back to r69921.  In
    https://gcc.gnu.org/pipermail/gcc-patches/2003-July/110632.html Nathan
    mentions that we only push dependent USING_DECLs, which is no longer the
    case; now that we retain more USING_DECLs, handling this case like the other
    overloaded function cases seems like the obvious solution.
    
    gcc/cp/ChangeLog:
    
            PR c++/92918
            * name-lookup.c (push_class_level_binding_1): Do overload a new
            function with a previous using-declaration.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/92918
            * g++.dg/lookup/using66.C: New test.

Diff:
---
 gcc/cp/name-lookup.c                  |  2 +-
 gcc/testsuite/g++.dg/lookup/using66.C | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 533d79542c9..f8caa16fc76 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -4552,7 +4552,7 @@ push_class_level_binding_1 (tree name, tree x)
 	old_decl = bval;
       else if (TREE_CODE (bval) == USING_DECL
 	       && OVL_P (target_decl))
-	return true;
+	old_decl = bval;
       else if (OVL_P (target_decl)
 	       && OVL_P (target_bval))
 	old_decl = bval;
diff --git a/gcc/testsuite/g++.dg/lookup/using66.C b/gcc/testsuite/g++.dg/lookup/using66.C
new file mode 100644
index 00000000000..02383bbea3e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using66.C
@@ -0,0 +1,23 @@
+// PR c++/92918
+// { dg-do compile { target c++11 } }
+
+struct Base03
+{
+    static void impl();
+};
+
+struct Problem : Base03
+{
+    using Base03::impl;
+    static int impl(char const *);
+
+    template <typename T>
+    auto f(const T &t) const
+    -> decltype(impl(t))
+    {
+        return impl(t);
+    }
+};
+
+Problem t;
+int i = t.f("42");


                 reply	other threads:[~2021-05-20 21:35 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=20210520213525.903343987C20@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).