1 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -pedantic -verify -fsyntax-only
9 typedef __SIZE_TYPE__ size_t;
14 void *operator new(size_t);
15 void operator delete(void *ptr);
19 // There are no global user-defined new operators at this point. Test that clang
20 // rejects these gracefully.
21 void test_default_new_delete(void *buffer, A **pa) {
22 A *a = new A; // expected-error {{'default new' is not supported in C++ for OpenCL}}
23 delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
24 *pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}}
27 // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
28 void *operator new(size_t _s, void *ptr) noexcept {
32 // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
33 void *operator new[](size_t _s, void *ptr) noexcept {
37 void test_new_delete(void *buffer, A **a, B **b) {
38 *a = new A; // expected-error {{no matching function for call to 'operator new'}}
39 delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
41 *a = new A[20]; // expected-error {{no matching function for call to 'operator new[]'}}
42 delete[] *a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
44 // User-defined placement new is supported.
47 // User-defined placement new[] is supported.
48 *a = new (buffer) A[30];
50 // User-defined new is supported.
53 // User-defined delete is supported.