1 // Tests that we'll find aligned allocation function properly.
2 // RUN: %clang_cc1 %s -std=c++20 %s -fsyntax-only -verify -fcoro-aligned-allocation
4 #include "Inputs/std-coroutine.h"
7 typedef __SIZE_TYPE__
size_t;
8 enum class align_val_t
: size_t {};
13 auto initial_suspend() { return std::suspend_always
{}; }
14 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
15 auto get_return_object() { return task
{}; }
16 void unhandled_exception() {}
17 void return_value(int) {}
18 void *operator new(std::size_t); // expected-warning 1+{{under -fcoro-aligned-allocation, the non-aligned allocation function for the promise type 'f' has higher precedence than the global aligned allocation function}}
28 auto initial_suspend() { return std::suspend_always
{}; }
29 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
30 auto get_return_object() { return task2
{}; }
31 void unhandled_exception() {}
32 void return_value(int) {}
33 void *operator new(std::size_t, std::align_val_t
);
37 // no diagnostic expected
44 auto initial_suspend() { return std::suspend_always
{}; }
45 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
46 auto get_return_object() { return task3
{}; }
47 void unhandled_exception() {}
48 void return_value(int) {}
49 void *operator new(std::size_t, std::align_val_t
) noexcept
;
50 void *operator new(std::size_t) noexcept
;
51 static auto get_return_object_on_allocation_failure() { return task3
{}; }
55 // no diagnostic expected
62 auto initial_suspend() { return std::suspend_always
{}; }
63 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
64 auto get_return_object() { return task4
{}; }
65 void unhandled_exception() {}
66 void return_value(int) {}
67 void *operator new(std::size_t, std::align_val_t
, int, double, int) noexcept
;
71 // no diagnostic expected
72 task4
f3(int, double, int) {
78 auto initial_suspend() { return std::suspend_always
{}; }
79 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
80 auto get_return_object() { return task5
{}; }
81 void unhandled_exception() {}
82 void return_value(int) {}
86 // no diagnostic expected.
87 // The aligned allocation will be declared by the compiler.
94 constexpr nothrow_t nothrow
= {};
99 auto initial_suspend() { return std::suspend_always
{}; }
100 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
101 auto get_return_object() { return task6
{}; }
102 void unhandled_exception() {}
103 void return_value(int) {}
104 static task6
get_return_object_on_allocation_failure() { return task6
{}; }
108 task6
f5() { // expected-error 1+{{unable to find '::operator new(size_t, align_val_t, nothrow_t)' for 'f5'}}
112 void *operator new(std::size_t, std::align_val_t
, std::nothrow_t
) noexcept
;