Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/alloc-02-fail-new-grooaf-check.C

raw
1 // { dg-do run }
2 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
3
4 /* check the code-gen for the failed alloc return.
5 In this case, we use an operator new that always fails.
6 So the g-r-o-o-a-f should fire. */
7
8 #define PROVIDE_GROOAF
9 #define USE_FAILING_OP_NEW
10 #include "../coro1-allocators.h"
11
12 int used_grooaf = 0;
13 int used_failing_new = 0;
14
15 struct coro1
16 f () noexcept
17 {
18 PRINT ("coro1: about to return");
19 co_return;
20 }
21
22 int main ()
23 {
24 /* nest a scope so that we can check the counts. */
25 {
26 PRINT ("main: create coro1");
27 struct coro1 x = f ();
28 /* we don't expect to be able to do anything. */
29 if (used_failing_new != 1)
30 {
31 PRINT ("main: we should have used the failing op new");
32 abort ();
33 }
34 if (used_grooaf != 1)
35 {
36 PRINT ("main: we should have used the GROOAF");
37 abort ();
38 }
39 }
40 PRINT ("main: returning");
41 return 0;
42 }