From 4fcf79c8ab835615aea0687195871ac43b84d156 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 22 Jun 2022 14:57:21 -0400 Subject: [PATCH] c++: class scope function lookup [PR105908] 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. 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 7b0638d..56256ba 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -7626,6 +7626,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 0000000..4feb3f8 --- /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 + int templated_func(); + + template + auto call_templated_func() -> decltype(templated_func()); +}; + +template +auto test::call_templated_func() -> decltype(templated_func()) +{ + return templated_func(); +} -- 2.7.4