/* Avoid error about taking the address of a constructor. */
function = TREE_OPERAND (function, 0);
- tsubst_flags_t subcomplain = complain;
- if (koenig_p && TREE_CODE (function) == FUNCTION_DECL)
- /* When KOENIG_P, we don't want to mark_used the callee before
- augmenting the overload set via ADL, so during this initial
- substitution we disable mark_used by setting tf_conv (68942). */
- subcomplain |= tf_conv;
- function = tsubst_expr (function, args, subcomplain, in_decl);
+ function = tsubst_expr (function, args, complain, in_decl);
if (BASELINK_P (function))
qualified_p = true;
if (type_dependent_expression_p (fn)
|| any_type_dependent_arguments_p (*args))
{
+ if (koenig_p
+ && TREE_CODE (orig_fn) == FUNCTION_DECL
+ && !fndecl_built_in_p (orig_fn))
+ /* For an ADL-enabled call where unqualified lookup found a
+ single non-template function, wrap it in an OVERLOAD so that
+ later substitution doesn't overeagerly mark the function as
+ used. */
+ orig_fn = ovl_make (orig_fn, NULL_TREE);
result = build_min_nt_call_vec (orig_fn, *args);
SET_EXPR_LOCATION (result, cp_expr_loc_or_input_loc (fn));
KOENIG_LOOKUP_P (result) = koenig_p;
--- /dev/null
+// PR c++/119034
+// { dg-do compile { target c++14 } }
+// A version of koenig12.C involving partial instantiation via a generic lambda.
+
+void foo(...) = delete;
+
+template <class T> void lookup(T t) { [](auto u) { foo(u); }(t); }
+
+namespace N {
+ struct A { };
+ int foo(A);
+}
+
+int main() {
+ lookup(N::A{});
+}