public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: class scope function lookup [PR105908]
@ 2022-06-22 22:00 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-06-22 22:00 UTC (permalink / raw)
  To: gcc-patches

In r12-1273 for PR91706, I removed the code in get_class_binding that
stripped BASELINK.  This testcase demonstrates that we still need to strip
it in outer_binding before putting the overload set in IDENTIFIER_BINDING,
for compatibility with bindings added directly for declarations.

Tested x86_64-pc-linux-gnu, applying to trunk.

	PR c++/105908

gcc/cp/ChangeLog:

	* name-lookup.cc (outer_binding): Strip BASELINK.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/trailing16.C: New test.
---
 gcc/cp/name-lookup.cc                   |  4 ++++
 gcc/testsuite/g++.dg/cpp0x/trailing16.C | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/trailing16.C

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 421bf2e4f7a..ce622761a1a 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -7629,6 +7629,10 @@ outer_binding (tree name,
 		/* Thread this new class-scope binding onto the
 		   IDENTIFIER_BINDING list so that future lookups
 		   find it quickly.  */
+		if (BASELINK_P (class_binding->value))
+		  /* Don't put a BASELINK in IDENTIFIER_BINDING.  */
+		  class_binding->value
+		    = BASELINK_FUNCTIONS (class_binding->value);
 		class_binding->previous = outer;
 		if (binding)
 		  binding->previous = class_binding;
diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing16.C b/gcc/testsuite/g++.dg/cpp0x/trailing16.C
new file mode 100644
index 00000000000..4feb3f81c27
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/trailing16.C
@@ -0,0 +1,17 @@
+// PR c++/105908
+// { dg-do compile { target c++11 } }
+
+struct test
+{
+  template <typename T>
+  int templated_func();
+
+  template <typename T>
+  auto call_templated_func() -> decltype(templated_func<T>());
+};
+
+template <typename T>
+auto test::call_templated_func() -> decltype(templated_func<T>())
+{
+  return templated_func<T>();
+}

base-commit: d68d366425369649cb4e25a07752e25a4fff52cf
-- 
2.27.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-22 22:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 22:00 [pushed] c++: class scope function lookup [PR105908] Jason Merrill

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).