15666d36cce566b59be271670364794de9803af04Douglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s
25666d36cce566b59be271670364794de9803af04Douglas Gregor
35666d36cce566b59be271670364794de9803af04Douglas Gregorvoid* operator new (__SIZE_TYPE__ size, void* ptr);
45666d36cce566b59be271670364794de9803af04Douglas Gregorvoid* operator new[](__SIZE_TYPE__ size, void* ptr);
55666d36cce566b59be271670364794de9803af04Douglas Gregor
65666d36cce566b59be271670364794de9803af04Douglas Gregortypedef int __attribute__((address_space(1))) int_1;
75666d36cce566b59be271670364794de9803af04Douglas Gregor
85666d36cce566b59be271670364794de9803af04Douglas Gregorvoid test_new(void *p) {
95666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
105666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
115666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
125666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
135666d36cce566b59be271670364794de9803af04Douglas Gregor
145666d36cce566b59be271670364794de9803af04Douglas Gregor  // Placement new
155666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new (p) int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
165666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new (p) __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
175666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new (p) int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
185666d36cce566b59be271670364794de9803af04Douglas Gregor  (void)new (p) __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
195666d36cce566b59be271670364794de9803af04Douglas Gregor}
205666d36cce566b59be271670364794de9803af04Douglas Gregor
215666d36cce566b59be271670364794de9803af04Douglas Gregorvoid test_delete(int_1 *ip1) {
225666d36cce566b59be271670364794de9803af04Douglas Gregor  delete ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
235666d36cce566b59be271670364794de9803af04Douglas Gregor  delete [] ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
245666d36cce566b59be271670364794de9803af04Douglas Gregor}
25