1 // RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
2 typedef __SIZE_TYPE__ size_t;
3
4 // Operator delete template for placement new with global lookup
5 template<int I>
6 struct X0 {
7 X0();
8
operator newX09 static void* operator new(size_t) {
10 return I; // expected-error{{cannot initialize}}
11 }
12
operator deleteX013 static void operator delete(void*) {
14 int *ip = I; // expected-error{{cannot initialize}}
15 }
16 };
17
test_X0()18 void test_X0() {
19 // Using the global operator new suppresses the search for a
20 // operator delete in the class.
21 ::new X0<2>;
22
23 new X0<3>; // expected-note 2{{instantiation}}
24 }
25
26 // Operator delete template for placement new[] with global lookup
27 template<int I>
28 struct X1 {
29 X1();
30
operator new[]X131 static void* operator new[](size_t) {
32 return I; // expected-error{{cannot initialize}}
33 }
34
operator delete[]X135 static void operator delete[](void*) {
36 int *ip = I; // expected-error{{cannot initialize}}
37 }
38 };
39
test_X1()40 void test_X1() {
41 // Using the global operator new suppresses the search for a
42 // operator delete in the class.
43 ::new X1<2> [17];
44
45 new X1<3> [17]; // expected-note 2{{instantiation}}
46 }
47