brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · bb69fd5 Raw
47 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s2typedef __SIZE_TYPE__ size_t;3 4// Operator delete template for placement new with global lookup5template<int I>6struct X0 {7  X0();8 9  static void* operator new(size_t) {10    return I; // expected-error{{cannot initialize}}11  }12 13  static void operator delete(void*) {14    int *ip = I; // expected-error{{cannot initialize}}15  }16};17 18void test_X0() {19  // Using the global operator new suppresses the search for a20  // 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 lookup27template<int I>28struct X1 {29  X1();30 31  static void* operator new[](size_t) {32    return I; // expected-error{{cannot initialize}}33  }34 35  static void operator delete[](void*) {36    int *ip = I; // expected-error{{cannot initialize}}37  }38};39 40void test_X1() {41  // Using the global operator new suppresses the search for a42  // operator delete in the class.43  ::new X1<2> [17];44 45  new X1<3> [17]; // expected-note 2{{instantiation}}46}47