diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/pt.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp23/static-operator-call5.C | 8 |
2 files changed, 13 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); diff --git a/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C new file mode 100644 index 0000000..ae022d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C @@ -0,0 +1,8 @@ +// PR c++/108526 +// { dg-do compile { target c++23 } } + +template<class> void f() +{ + auto a = [] (auto x) static { return x; }; +} +template void f<int>(); |