1 // RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
2 typedef __SIZE_TYPE__
size_t;
4 // Overloaded operator delete with two arguments
8 static void* operator new(size_t);
9 static void operator delete(void*, size_t) {
10 int *ip
= I
; // expected-error{{cannot initialize}}
15 new X0
<1>; // expected-note{{instantiation}}
18 // Overloaded operator delete with one argument
23 static void* operator new(size_t);
24 static void operator delete(void*) {
25 int *ip
= I
; // expected-error{{cannot initialize}}
30 new X1
<1>; // expected-note{{instantiation}}
33 // Overloaded operator delete for placement new
38 static void* operator new(size_t, double, double);
39 static void* operator new(size_t, int, int);
41 static void operator delete(void*, const int, int) {
42 int *ip
= I
; // expected-error{{cannot initialize}}
45 static void operator delete(void*, double, double);
49 new (0, 0) X2
<1>; // expected-note{{instantiation}}
52 // Operator delete template for placement new
56 static void* operator new(size_t, double, double);
59 static void operator delete(void*, T x
, T
) {
61 int *ip
= &x
; // expected-error{{cannot initialize}}
66 new (0, 0) X3
; // expected-note{{instantiation}}
69 // Operator delete template for placement new in global scope.
72 static void* operator new(size_t, double, double);
76 void operator delete(void*, T x
, T
) {
78 int *ip
= &x
; // expected-error{{cannot initialize}}
82 new (0, 0) X4
; // expected-note{{instantiation}}
85 // Useless operator delete hides global operator delete template.
88 static void* operator new(size_t, double, double);
89 void operator delete(void*, double*, double*);
93 new (0, 0) X5
; // okay, we found X5::operator delete but didn't pick it
96 // Operator delete template for placement new
101 static void* operator new(size_t) {
102 return I
; // expected-error{{cannot initialize}}
105 static void operator delete(void*) {
106 int *ip
= I
; // expected-error{{cannot initialize}}
111 new X6
<3>; // expected-note 2{{instantiation}}
114 void *operator new(size_t, double, double, double);
117 void operator delete(void*, T x
, T
, T
) {
119 int *ip
= &x
; // expected-error{{cannot initialize}}
121 void test_int_new() {
122 new (1.0, 1.0, 1.0) int; // expected-note{{instantiation}}
125 // We don't need an operator delete if the type has a trivial
126 // constructor, since we know that constructor cannot throw.
127 // FIXME: Is this within the standard? Seems fishy, but both EDG+GCC do it.
131 static void* operator new(size_t);
132 static void operator delete(void*, size_t) {
133 int *ip
= I
; // okay, since it isn't instantiated.