Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/consteval26.C

raw
1 // PR c++/103912
2 // { dg-do run { target c++20 } }
3 // { dg-additional-options "-O2 -g -fkeep-inline-functions" }
4
5 extern "C" void abort ();
6
7 struct A { A () {} };
8
9 consteval auto
10 foo ()
11 {
12 if (1)
13 ;
14 return [] (A x) { return 1; };
15 }
16
17 consteval auto
18 bar (int a)
19 {
20 int b = a + 4;
21 if (1)
22 ;
23 return [=] (A x) { return a + b; };
24 }
25
26 int
27 main ()
28 {
29 A x;
30 auto h = foo ();
31 if (h (x) != 1)
32 abort ();
33 auto i = bar (5);
34 if (i (x) != 14)
35 abort ();
36 auto j = bar (42);
37 if (j (x) != 88)
38 abort ();
39 }