2009-06-01 05:53:59 +08:00
|
|
|
// RUN: clang-cc %s -emit-llvm -o %t &&
|
2009-06-01 04:21:44 +08:00
|
|
|
|
|
|
|
void t1() {
|
|
|
|
int* a = new int;
|
|
|
|
}
|
2009-06-01 04:26:12 +08:00
|
|
|
|
|
|
|
// Placement.
|
|
|
|
void* operator new(unsigned long, void*) throw();
|
|
|
|
|
|
|
|
void t2(int* a) {
|
|
|
|
int* b = new (a) int;
|
|
|
|
}
|
2009-06-01 04:56:36 +08:00
|
|
|
|
2009-06-01 05:12:26 +08:00
|
|
|
struct S {
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
|
2009-06-01 05:53:59 +08:00
|
|
|
// POD types.
|
2009-06-01 04:56:36 +08:00
|
|
|
void t3() {
|
|
|
|
int *a = new int(10);
|
2009-06-01 05:07:58 +08:00
|
|
|
_Complex int* b = new _Complex int(10i);
|
|
|
|
|
2009-06-01 05:12:26 +08:00
|
|
|
S s;
|
|
|
|
s.a = 10;
|
|
|
|
S *sp = new S(s);
|
2009-06-01 04:56:36 +08:00
|
|
|
}
|
2009-06-01 05:53:59 +08:00
|
|
|
|
|
|
|
// Non-POD
|
|
|
|
struct T {
|
|
|
|
T();
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
|
|
|
|
void t4() {
|
|
|
|
// RUN: grep "call void @_ZN1TC1Ev" %t | count 1 &&
|
|
|
|
T *t = new T;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct T2 {
|
|
|
|
int a;
|
|
|
|
T2(int, int);
|
|
|
|
};
|
|
|
|
|
|
|
|
void t5() {
|
|
|
|
// RUN: grep "call void @_ZN2T2C1Eii" %t | count 1
|
|
|
|
T2 *t2 = new T2(10, 10);
|
|
|
|
}
|
2009-06-01 08:05:16 +08:00
|
|
|
|
|
|
|
int *t6() {
|
|
|
|
// Null check.
|
|
|
|
return new (0) int(10);
|
|
|
|
}
|
2009-06-01 08:26:14 +08:00
|
|
|
|
|
|
|
void t7() {
|
|
|
|
new int();
|
|
|
|
}
|