Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/alloc-01-overload-newdel.C

raw
1 // { dg-do run }
2 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
3
4 // check codegen for overloaded simple operator new/delete.
5
6 #define PROVIDE_NEW_SZT
7 #define PROVIDE_DEL_VP
8
9 #include "../coro1-allocators.h"
10
11 int used_ovl_new = 0;
12 int used_ovl_del = 0;
13
14 struct coro1
15 f () noexcept
16 {
17 PRINT ("coro1: about to return");
18 co_return;
19 }
20
21 int main ()
22 {
23 // Nest a scope so that we can inspect the flags after the DTORs run.
24 {
25 PRINT ("main: create coro1");
26 struct coro1 x = f ();
27 PRINT ("main: got coro1 - resuming");
28 if (x.handle.done())
29 abort();
30 x.handle.resume();
31 PRINT ("main: after resume");
32 if (!x.handle.done())
33 {
34 PRINT ("main: apparently not done...");
35 abort ();
36 }
37 }
38 if (used_ovl_new != 1)
39 {
40 PRINT ("main: failed to call overloaded operator new");
41 abort ();
42 }
43 if (used_ovl_del != 1)
44 {
45 PRINT ("main: failed to call overloaded operator delete");
46 abort ();
47 }
48 PRINT ("main: returning");
49 return 0;
50 }