new.cpp revision 215bd208d6eeff397bc4316d046ea8b4633efedf
1// RUN: clang-cc %s -emit-llvm -o %t && 2 3void t1() { 4 int* a = new int; 5} 6 7// Placement. 8void* operator new(unsigned long, void*) throw(); 9 10void t2(int* a) { 11 int* b = new (a) int; 12} 13 14struct S { 15 int a; 16}; 17 18// POD types. 19void t3() { 20 int *a = new int(10); 21 _Complex int* b = new _Complex int(10i); 22 23 S s; 24 s.a = 10; 25 S *sp = new S(s); 26} 27 28// Non-POD 29struct T { 30 T(); 31 int a; 32}; 33 34void t4() { 35 // RUN: grep "call void @_ZN1TC1Ev" %t | count 1 && 36 T *t = new T; 37} 38 39struct T2 { 40 int a; 41 T2(int, int); 42}; 43 44void t5() { 45 // RUN: grep "call void @_ZN2T2C1Eii" %t | count 1 46 T2 *t2 = new T2(10, 10); 47} 48 49int *t6() { 50 // Null check. 51 return new (0) int(10); 52} 53 54void t7() { 55 new int(); 56} 57