aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-02-12 16:10:38 +0100
committerIain Sandoe <iain@sandoe.co.uk>2020-02-12 23:27:26 +0100
commit68bb7e3b9dc3be6c9ceecc2c87b9c678e1a045dc (patch)
tree3f4ee92a525857621540fe82a3d90b5be16b2e59 /gcc/fold-const.c
parent1cd9bef89ef25b3fd506cedbc82e8bc00ff56fa8 (diff)
downloadgcc-68bb7e3b9dc3be6c9ceecc2c87b9c678e1a045dc.zip
gcc-68bb7e3b9dc3be6c9ceecc2c87b9c678e1a045dc.tar.gz
gcc-68bb7e3b9dc3be6c9ceecc2c87b9c678e1a045dc.tar.bz2
coroutines: Update to n4849 allocation/deallocation.
This updates the coroutine frame allocation and deallocation usage to match n4849. [dcl.fct.def.coroutine] /9, /10, /12. 9 An implementation may need to allocate additional storage for a coroutine. This storage is known as the coroutine state and is obtained by calling a non-array allocation function. The allocation function’s name is looked up in the scope of the promise type. If this lookup fails, the allocation function’s name is looked up in the global scope. If the lookup finds an allocation function in the scope of the promise type, overload resolution is performed on a function call created by assembling an argument list. The first argument is the amount of space requested, and has type std::size_t. The lvalues p1 . . . pn are the succeeding [user's function] arguments. If no viable function is found, overload resolution is performed again on a function call created by passing just the amount of space required as an argument of type std::size_t. 10 The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of the promise type by class member access lookup. If any declarations are found, then the result of a call to an allocation function used to obtain storage for the coroutine state is assumed to return nullptr if it fails to obtain storage, and if a global allocation function is selected, the ::operator new(size_t, nothrow_t) form is used. The allocation function used in this case shall have a non-throwing noexcept-specification. If the allocation function returns nullptr, the coroutine returns control to the caller of the coroutine and the return value is obtained by a call to T::get_return_object_on_allocation_failure(), where T is the promise type. 12 The deallocation function’s name is looked up in the scope of the promise type. If this lookup fails, the deallocation function’s name is looked up in the global scope. If deallocation function lookup finds both a usual deallocation function with only a pointer parameter and a usual deallocation function with both a pointer parameter and a size parameter, then the selected deallocation function shall be the one with two parameters. Otherwise, the selected deallocation function shall be the function with one parameter. If no usual deallocation function is found, the program is ill- formed. The selected deallocation function shall be called with the address of the block of storage to be reclaimed as its first argument. If a deallocation function with a parameter of type std::size_t is used, the size of the block is passed as the corresponding argument. gcc/cp/ChangeLog: 2020-02-12 Iain Sandoe <iain@sandoe.co.uk> * coroutines.cc (build_actor_fn): Implement deallocation function selection per n4849, dcl.fct.def.coroutine bullet 12. (morph_fn_to_coro): Implement allocation function selection per n4849, dcl.fct.def.coroutine bullets 9 and 10. 2020-02-12 Iain Sandoe <iain@sandoe.co.uk> * g++.dg/coroutines/coro1-allocators.h: New. * g++.dg/coroutines/coro-bad-alloc-00-bad-op-new.C: New test. * g++.dg/coroutines/coro-bad-alloc-01-bad-op-del.C: New test. * g++.dg/coroutines/coro-bad-alloc-02-no-op-new-nt.C: New test. * g++.dg/coroutines/torture/alloc-00-gro-on-alloc-fail.C: Use new coro1-allocators.h header. * g++.dg/coroutines/torture/alloc-01-overload-newdel.C: Likewise. * g++.dg/coroutines/torture/alloc-02-fail-new-grooaf-check.C: New. * g++.dg/coroutines/torture/alloc-03-overload-new-1.C: New test. * g++.dg/coroutines/torture/alloc-04-overload-del-use-two-args.C:New.
Diffstat (limited to 'gcc/fold-const.c')
0 files changed, 0 insertions, 0 deletions