Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / expr / expr.unary / expr.new / p19.cpp
blobbb69fd55fd8034abbb1abc83c4d66aa3b0583fc4
1 // RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
2 typedef __SIZE_TYPE__ size_t;
4 // Operator delete template for placement new with global lookup
5 template<int I>
6 struct X0 {
7 X0();
9 static void* operator new(size_t) {
10 return I; // expected-error{{cannot initialize}}
13 static void operator delete(void*) {
14 int *ip = I; // expected-error{{cannot initialize}}
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>;
23 new X0<3>; // expected-note 2{{instantiation}}
26 // Operator delete template for placement new[] with global lookup
27 template<int I>
28 struct X1 {
29 X1();
31 static void* operator new[](size_t) {
32 return I; // expected-error{{cannot initialize}}
35 static void operator delete[](void*) {
36 int *ip = I; // expected-error{{cannot initialize}}
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];
45 new X1<3> [17]; // expected-note 2{{instantiation}}