+2019-02-13 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/87322
+ * pt.c (tsubst_lambda_expr): Avoid duplicate tsubsting.
+ Move cp_evaluated resetting before signature tsubsting.
+ (gen_elem_of_pack_expansion_instantiation): Separate local
+ specializations per index.
+
2019-02-13 David Malcolm <dmalcolm@redhat.com>
PR c++/89036
ARGUMENT_PACK_SELECT_INDEX (aps) = index;
}
+ // Any local specialization bindings arising from this substitution
+ // cannot be reused for a different INDEX.
+ local_specialization_stack lss (lss_copy);
+
/* Substitute into the PATTERN with the (possibly altered)
arguments. */
if (pattern == in_decl)
tree oldfn = lambda_function (t);
in_decl = oldfn;
+ /* If we have already specialized this lambda expr, reuse it. See
+ PR c++/87322. */
+ if (local_specializations)
+ if (tree r = retrieve_local_specialization (t))
+ return r;
+
tree r = build_lambda_expr ();
+ if (local_specializations)
+ register_local_specialization (r, t);
+
LAMBDA_EXPR_LOCATION (r)
= LAMBDA_EXPR_LOCATION (t);
LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (r)
r = error_mark_node;
else
{
+ /* The body of a lambda-expression is not a subexpression of the
+ enclosing expression. Parms are to have DECL_CHAIN tsubsted,
+ which would be skipped if cp_unevaluated_operand. */
+ cp_evaluated ev;
+
/* Fix the type of 'this'. */
fntype = build_memfn_type (fntype, type,
type_memfn_quals (fntype),
/* Let finish_function set this. */
DECL_DECLARED_CONSTEXPR_P (fn) = false;
- /* The body of a lambda-expression is not a subexpression of the
- enclosing expression. */
- cp_evaluated ev;
-
bool nested = cfun;
if (nested)
push_function_context ();
+2019-02-13 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/87322
+ * g++.dg/cpp1y/pr87322.C: New.
+ * g++.dg/cpp0x/lambda/lambda-variadic5.C: Test that we
+ instantiate the expected number of lambda functions.
+
2019-02-13 Marek Polacek <polacek@redhat.com>
PR c++/77304
--- /dev/null
+// { dg-do compile { target c++14 } }
+
+#include <array>
+#include <algorithm>
+
+int main()
+{
+ constexpr std::array<std::array<double,2>,3> my_mat {
+ { { 1., 1. },
+ { 1., 1. },
+ { 1., 1. }, }
+ };
+
+ std::for_each(my_mat.begin(), my_mat.end(), [
+ inner_func = [] (auto a, auto b) { return a + b; } ](auto& row) {
+ std::for_each(row.begin(), row.end(), [&,
+ inner_func2 = [] (auto a, auto b) { return a + b; } ]
+ (const double&) {
+ return;
+ });
+ });
+
+}