2 // { dg-do run { target c++14 } }
4 // Check we don't capture this (too) unnecessarily
9 static void f (double) {}
11 static void g (int) {}
12 static void g (double) {}
17 static void x (double) {}
24 int Check (bool expect, unsigned size)
26 return (expect ? sizeof (void *) : 1) != size;
32 // one of the functions is non-static
33 auto l0 = [&](auto z) { f (z); };
34 r += Check (true, sizeof l0);
35 l0(0.0); // doesn't need this capture for A::f(double), but too late
36 l0 (0); // Needs this capture for A::f(int)
38 // no fn is non-static.
39 auto l00 = [&](auto z) { g (z); };
40 r += Check (false, sizeof l00);
44 // sizeof isn't an evaluation context, so no this capture
45 auto l1 = [&](auto z) { sizeof (f (z), 1); };
46 r += Check (false, sizeof l1);
49 auto l2 = [&](auto) { f (2.4); };
50 auto l3 = [&](auto) { f (0); };
51 l2(0); l3(0); l2(0.0); l3 (0.0);
52 r += Check (false, sizeof l2);
53 r += Check (true, sizeof l3);
55 auto l4 = [&](auto) { O::x (2.4); };
56 auto l5 = [&](auto) { N::y (2.4); };
57 auto l6 = [&](auto) { };
59 l4(0.0); l5(0.0); l6(0.0);
60 r += Check (false, sizeof l4);
61 r += Check (false, sizeof l5);
62 r += Check (false, sizeof l6);
71 return a.b () ? 1 : 0;