Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/alloc-04-overload-del-use-two-args.C

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