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