freebsd-dev/test/CodeGenCXX/new.cpp

75 lines
846 B
C++
Raw Normal View History

2009-10-14 18:03:49 +00:00
// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
2009-11-18 14:59:57 +00:00
#include <stddef.h>
2009-06-02 17:58:47 +00:00
void t1() {
int* a = new int;
}
// Placement.
2009-11-18 14:59:57 +00:00
void* operator new(size_t, void*) throw();
2009-06-02 17:58:47 +00:00
void t2(int* a) {
int* b = new (a) int;
}
struct S {
int a;
};
// POD types.
void t3() {
int *a = new int(10);
_Complex int* b = new _Complex int(10i);
S s;
s.a = 10;
S *sp = new S(s);
}
// Non-POD
struct T {
T();
int a;
};
void t4() {
2009-10-14 18:03:49 +00:00
// CHECK: call void @_ZN1TC1Ev
2009-06-02 17:58:47 +00:00
T *t = new T;
}
struct T2 {
int a;
T2(int, int);
};
void t5() {
2009-10-14 18:03:49 +00:00
// CHECK: call void @_ZN2T2C1Eii
2009-06-02 17:58:47 +00:00
T2 *t2 = new T2(10, 10);
}
int *t6() {
// Null check.
return new (0) int(10);
}
void t7() {
new int();
}
2009-10-14 18:03:49 +00:00
struct U {
~U();
};
void t8(int n) {
new int[10];
new int[n];
// Non-POD
new T[10];
new T[n];
// Cookie required
new U[10];
new U[n];
}