/*done=*/false,
/*address_p=*/false);
}
- else if (koenig_p && identifier_p (function))
+ else if (koenig_p
+ && (identifier_p (function)
+ || (TREE_CODE (function) == TEMPLATE_ID_EXPR
+ && identifier_p (TREE_OPERAND (function, 0)))))
{
/* Do nothing; calling tsubst_copy_and_build on an identifier
would incorrectly perform unqualified lookup again.
FIXME but doing that causes c++/15272, so we need to stop
using IDENTIFIER_NODE in that situation. */
qualified_p = false;
+
+ if (TREE_CODE (function) == TEMPLATE_ID_EXPR)
+ /* Use tsubst_copy to substitute through the template arguments
+ of the template-id without performing unqualified lookup of
+ the template name. */
+ function = tsubst_copy (function, args, complain, in_decl);
}
else
{
template<int N, typename T>
concept Foo = requires(T t) { foo<N + 1>(t); }; // { dg-error "template instantiation depth" }
-template<int N = 1, typename T = int>
- requires Foo<N, T>
-int foo(T t)
+namespace ns
{
- return foo<N + 1>(t);
+ struct S { };
+
+ template<int N, typename T>
+ requires Foo<N, T>
+ int foo(T t)
+ {
+ return foo<N + 1>(t);
+ }
}
int main(int, char**)
{
- return foo<1>(1);
+ return foo<1>(ns::S{});
}
// { dg-prune-output "compilation terminated" }
--- /dev/null
+// PR c++/102670
+// { dg-do compile { target c++20 } }
+
+namespace ns {
+ struct S { };
+
+ template<int I>
+ constexpr int adl(const S &) {
+ return I;
+ }
+}
+
+namespace redirect {
+ template<class T, int I>
+ concept can_call_adl = requires(T t) {
+ adl<I>(t);
+ };
+
+ template<int I>
+ struct adl_fn {
+ template<can_call_adl<I> T>
+ constexpr decltype(auto) operator()(T t) const {
+ return adl<I>(t);
+ }
+ };
+
+ namespace {
+ template<int I>
+ constexpr inline adl_fn<I> adl{};
+ }
+}
+
+int main() {
+ static_assert(redirect::can_call_adl<ns::S, 3>);
+ redirect::adl<3>(ns::S{});
+}