aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-01-24 15:29:35 -0500
committerJason Merrill <jason@redhat.com>2023-01-24 17:11:52 -0500
commit39ade88fa1632c659c5c4ed065fa2b62d16a8670 (patch)
treee0c78eb5f4e883d2c314a33cca76fbf1ebe3939d /gcc/cp
parent1c407dc088231ba5f2cc63d9278f4b797db48de1 (diff)
downloadgcc-39ade88fa1632c659c5c4ed065fa2b62d16a8670.zip
gcc-39ade88fa1632c659c5c4ed065fa2b62d16a8670.tar.gz
gcc-39ade88fa1632c659c5c4ed065fa2b62d16a8670.tar.bz2
c++: static lambda in template [PR108526]
tsubst_lambda_expr uses build_memfn_type to build a METHOD_TYPE for the new lamba op(). This is not what we want for a C++23 static op(), but since we also use that METHOD_TYPE to communicate the closure type down to tsubst_function_decl, let's wait and turn it back at that point. PR c++/108526 gcc/cp/ChangeLog: * pt.cc (tsubst_function_decl): Handle static lambda. gcc/testsuite/ChangeLog: * g++.dg/cpp23/static-operator-call5.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2a4d03c..51fc246 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -14306,6 +14306,11 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
tree ctx = closure ? closure : DECL_CONTEXT (t);
bool member = ctx && TYPE_P (ctx);
+ /* If this is a static lambda, remove the 'this' pointer added in
+ tsubst_lambda_expr now that we know the closure type. */
+ if (lambda_fntype && DECL_STATIC_FUNCTION_P (t))
+ lambda_fntype = static_fn_type (lambda_fntype);
+
if (member && !closure)
ctx = tsubst_aggr_type (ctx, args,
complain, t, /*entering_scope=*/1);