2014-03-08 Adam Butcher <adam@jessamine.co.uk>
+ PR c++/60033
+ * pt.c (tsubst_copy): When retrieving a capture pack from a generic
+ lambda, remove the lambda's own template argument list prior to fetching
+ the specialization.
+
PR c++/60393
* parser.c (cp_parser_parameter_declaration_clause): Move generic
function template unwinding on error into a more general location, ...
{
/* Check for a local specialization set up by
tsubst_pack_expansion. */
- tree r = retrieve_local_specialization (t);
- if (r)
+ if (tree r = retrieve_local_specialization (t))
{
if (TREE_CODE (r) == ARGUMENT_PACK_SELECT)
r = ARGUMENT_PACK_SELECT_ARG (r);
return r;
}
+ /* When retrieving a capture pack from a generic lambda, remove the
+ lambda call op's own template argument list from ARGS. Only the
+ template arguments active for the closure type should be used to
+ retrieve the pack specialization. */
+ if (LAMBDA_FUNCTION_P (current_function_decl)
+ && (template_class_depth (DECL_CONTEXT (t))
+ != TMPL_ARGS_DEPTH (args)))
+ args = strip_innermost_template_args (args, 1);
+
/* Otherwise return the full NONTYPE_ARGUMENT_PACK that
tsubst_decl put in the hash table. */
return retrieve_specialization (t, args, 0);
--- /dev/null
+// PR c++/60033
+// { dg-options -std=c++1y }
+
+template <typename... T>
+auto f(T&&... ts)
+{
+ return sizeof...(ts);
+}
+
+template <typename... T>
+auto g(T&&... ts) {
+ return [&] (auto v) {
+ return f(ts...);
+ };
+}
+
+int main()
+{
+ return g(1,2,3,4)(5) == 4 ? 0 : 1;
+}