Lines Matching +defs:std +defs:string

1 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s -DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete
2 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" "-DDELETE=operator delete"
3 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" "-DDELETE=::operator delete"
4 // RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" "-DDELETE=::operator delete"
7 void *p = NEW(sizeof(int)); // expected-note {{cannot allocate untyped memory in a constant expression; use 'std::allocator<T>::allocate'}}
13 namespace std {
20 DELETE(p); // #dealloc expected-note 2{{'std::allocator<...>::deallocate' used to delete pointer to object allocated with 'new'}}
26 std::allocator<int> alloc;
33 template<> struct std::allocator<void()> {
36 constexpr void *fn = std::allocator<void()>().allocate(); // expected-error {{constant expression}} expected-note {{in call}}
39 template<> struct std::allocator<Incomplete> {
42 constexpr void *incomplete = std::allocator<Incomplete>().allocate(); // expected-error {{constant expression}} expected-note {{in call}}
46 template<> struct std::allocator<WrongSize> {
49 constexpr void *wrong_size = std::allocator<WrongSize>().allocate(); // expected-error {{constant expression}} expected-note {{in call}}
61 p = std::allocator<int>().allocate(1); // expected-note 2{{heap allocation}}
66 delete p; // expected-note {{'delete' used to delete pointer to object allocated with 'std::allocator<...>::allocate'}}
69 delete[] p; // expected-note {{'delete' used to delete pointer to object allocated with 'std::allocator<...>::allocate'}}
72 std::allocator<int>().deallocate(p); // expected-note 2{{in call}}
83 constexpr int *escape = std::allocator<int>().allocate(3); // expected-error {{constant expression}} expected-note {{pointer to subobject of heap-allocated}} \
85 constexpr int leak = (std::allocator<int>().allocate(3), 0); // expected-error {{constant expression}} \
87 constexpr int no_lifetime_start = (*std::allocator<int>().allocate(1) = 1); // expected-error {{constant expression}} expected-note {{assignment to object outside its lifetime}}
88 constexpr int no_deallocate_nullptr = (std::allocator<int>().deallocate(nullptr), 1); // expected-error {{constant expression}} expected-note {{in call}}
89 // expected-note@#dealloc {{'std::allocator<...>::deallocate' used to delete a null pointer}}
90 constexpr int no_deallocate_nonalloc = (std::allocator<int>().deallocate((int*)&no_deallocate_nonalloc), 1); // expected-error {{constant expression}} expected-note {{in call}}
94 void *operator new(std::size_t, void *p) { return p; }
95 void* operator new[] (std::size_t, void* p) {return p;}
102 namespace std {
109 static_assert(std::placement_new_in_stdlib());
111 namespace std {
119 int *p = std::allocator<int>().allocate(3);
120 std::construct_at<int>(p, 1);
121 std::construct_at<int>(p + 1, 2);
122 std::construct_at<int>(p + 2, 3);
124 std::allocator<int>().deallocate(p);
132 std::construct_at<float>(&a, 1.0f); // expected-note {{in call}}
145 std::construct_at<int>(&a.x.a, 1); // expected-note {{in call}}
156 std::construct_at<int>(&u.b, 2);
163 static_assert((std::construct_at<int>(&external, 1), true)); // expected-error{{}} expected-note {{in call}}
167 static_assert((std::construct_at<int>(&temporary, 1), true)); // expected-error{{}} expected-note {{in call}}
173 std::construct_at<int>(p); // expected-note {{in call}}
182 std::construct_at<A::B>(&a.b); // expected-note {{in call}}
195 std::construct_at<A>(p);
203 std::construct_at<A>(p);
210 std::allocator<A> alloc;
212 std::construct_at<A>(p);
214 std::construct_at<A>(p);
224 class string {
227 constexpr string() {
230 constexpr ~string() {
241 test<string().size()>();