aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/new.cpp
blob: e3d1ec1df6c9ba6267b0c05d3c55f89eba5e1144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: clang-cc %s -emit-llvm -o %t &&

void t1() {
  int* a = new int;
}

// Placement.
void* operator new(unsigned long, void*) throw();

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() {
  // 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);
}