Lambdas used as non-type template arguments to concepts are wrapped
in TARGET_EXPR nodes. After r16-5115 changed convert_template_argument
to call instantiate_non_dependent_expr_internal on non-dependent
expressions, these TARGET_EXPRs began hitting the default case in
tsubst_expr, causing an ICE. Add proper TARGET_EXPR handling.
PR c++/117034
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr): Add case TARGET_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-template-pr117034.C: New test.
---
Bootstrapped and regtested on x86_64-pc-linux-gnu with no new regressions.
gcc/cp/pt.cc | 7 +++++++
gcc/testsuite/g++.dg/cpp2a/lambda-template-pr117034.C | 7 +++++++
2 files changed, 14 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/lambda-template-pr117034.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4dc8f980d0d..9dd218ffe37 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22300,6 +22300,13 @@ tsubst_expr (tree t, tree args, tsubst_flags_t
complain, tree in_decl)
RETURN (build_typeid (operand_0, complain));
}
}
+ case TARGET_EXPR:
+ {
+ tree init = RECUR (TREE_OPERAND (t, 1));
+ if (init == TREE_OPERAND (t, 1))
+ RETURN (t);
+ RETURN (get_target_expr (init, complain));
+ }
case FUNCTION_DECL:
case PARM_DECL:
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-template-pr117034.C
b/gcc/testsuite/g++.dg/cpp2a/lambda-template-pr117034.C
new file mode 100644
index 00000000000..b9b2773b923
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-template-pr117034.C
@@ -0,0 +1,7 @@
+// { dg-do compile { target c++20 } }
+// PR c++/117034
+
+template<typename, auto>
+concept A = true;
+
+void f(A<[] {}> auto) {}
--
2.52.0