| 1 |
// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility %s -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fms-compatibility -emit-pch -o %t %s |
| 3 |
// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility -include-pch %t -verify %s -o - | FileCheck %s |
| 4 |
// expected-no-diagnostics |
| 5 |
|
| 6 |
#ifndef HEADER |
| 7 |
#define HEADER |
| 8 |
|
| 9 |
class Test1 { |
| 10 |
private: |
| 11 |
int x_; |
| 12 |
double y_; |
| 13 |
|
| 14 |
public: |
| 15 |
Test1(int x) : x_(x) {} |
| 16 |
__declspec(property(get = get_x)) int X; |
| 17 |
int get_x() const { return x_; } |
| 18 |
static Test1 *GetTest1() { return new Test1(10); } |
| 19 |
}; |
| 20 |
|
| 21 |
class S { |
| 22 |
public: |
| 23 |
__declspec(property(get=GetX,put=PutX)) int x[]; |
| 24 |
int GetX(int i, int j) { return i+j; } |
| 25 |
void PutX(int i, int j, int k) { j = i = k; } |
| 26 |
__declspec(property(get=GetY,put=PutY)) int y[][]; |
| 27 |
int GetY(int i, int j) { return i+j; } |
| 28 |
void PutY(int i, int j, int k) { j = i = k; } |
| 29 |
__declspec(property(get=GetZ,put=PutZ)) int z[][][]; |
| 30 |
int GetZ(int i, int j, int k) { return i+j+k; } |
| 31 |
void PutZ(int i, int j, int k, int v) { j = i = k = v; } |
| 32 |
}; |
| 33 |
|
| 34 |
template <typename T> |
| 35 |
class St { |
| 36 |
public: |
| 37 |
__declspec(property(get=GetX,put=PutX)) T x[]; |
| 38 |
T GetX(T i, T j) { return i+j; } |
| 39 |
T GetX() { return 0; } |
| 40 |
T PutX(T i, T j, T k) { return j = i = k; } |
| 41 |
__declspec(property(get=GetY,put=PutY)) T y[]; |
| 42 |
char GetY(char i, Test1 j) { return i+j.get_x(); } |
| 43 |
void PutY(char i, int j, double k) { j = i = k; } |
| 44 |
}; |
| 45 |
|
| 46 |
template <typename T> |
| 47 |
void foo(T i, T j) { |
| 48 |
St<T> bar; |
| 49 |
Test1 t(i); |
| 50 |
bar.x[i][j] = bar.x[i][j]; |
| 51 |
bar.y[t.X][j] = bar.x[i][j]; |
| 52 |
bar.x[i][j] = bar.y[bar.x[i][j]][t]; |
| 53 |
} |
| 54 |
|
| 55 |
int idx() { return 7; } |
| 56 |
|
| 57 |
// CHECK-LABEL: main |
| 58 |
int main(int argc, char **argv) { |
| 59 |
Test1 t(argc); |
| 60 |
S *p1 = 0; |
| 61 |
St<float> *p2 = 0; |
| 62 |
// CHECK: call noundef i32 @"?GetX@S@@QEAAHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 223, i32 noundef 11) |
| 63 |
int j = p1->x[223][11]; |
| 64 |
// CHECK: [[J:%.+]] = load i32, ptr % |
| 65 |
// CHECK-NEXT: call void @"?PutX@S@@QEAAXHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 23, i32 noundef 1, i32 noundef [[J]]) |
| 66 |
p1->x[23][1] = j; |
| 67 |
// CHECK: call noundef i32 @"?GetY@S@@QEAAHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 123, i32 noundef 22) |
| 68 |
int k = p1->y[123][22]; |
| 69 |
// CHECK: [[K:%.+]] = load i32, ptr % |
| 70 |
// CHECK-NEXT: call void @"?PutY@S@@QEAAXHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 16, i32 noundef 2, i32 noundef [[K]]) |
| 71 |
p1->y[16][2] = k; |
| 72 |
// CHECK: call noundef i32 @"?GetZ@S@@QEAAHHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 123, i32 noundef 22, i32 noundef 44) |
| 73 |
k = p1->z[123][22][44]; |
| 74 |
// CHECK: [[K:%.+]] = load i32, ptr % |
| 75 |
// CHECK-NEXT: call void @"?PutZ@S@@QEAAXHHHH@Z"(ptr {{[^,]*}} %{{.+}}, i32 noundef 16, i32 noundef 2, i32 noundef 32, i32 noundef [[K]]) |
| 76 |
p1->z[16][2][32] = k; |
| 77 |
// CHECK: call noundef float @"?GetX@?$St@M@@QEAAMMM@Z"(ptr {{[^,]*}} %{{.+}}, float noundef 2.230000e+02, float noundef 1.100000e+01) |
| 78 |
float j1 = p2->x[223][11]; |
| 79 |
// CHECK: [[J1:%.+]] = load float, ptr % |
| 80 |
// CHECK-NEXT: [[CALL:%.+]] = call noundef float @"?PutX@?$St@M@@QEAAMMMM@Z"(ptr {{[^,]*}} %{{.+}}, float noundef 2.300000e+01, float noundef 1.000000e+00, float noundef [[J1]]) |
| 81 |
// CHECK-NEXT: [[CONV:%.+]] = fptosi float [[CALL]] to i32 |
| 82 |
// CHECK-NEXT: store i32 [[CONV]], ptr |
| 83 |
argc = p2->x[23][1] = j1; |
| 84 |
// CHECK: [[IDX:%.+]] = call noundef i32 @"?idx@@YAHXZ"() |
| 85 |
// CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float |
| 86 |
// CHECK-NEXT: [[GET:%.+]] = call noundef float @"?GetX@?$St@M@@QEAAMMM@Z"(ptr {{[^,]*}} %{{.+}}, float noundef [[CONV]], float noundef 1.000000e+00) |
| 87 |
// CHECK-NEXT: [[INC:%.+]] = fadd float [[GET]], 1.000000e+00 |
| 88 |
// CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float |
| 89 |
// CHECK-NEXT: call noundef float @"?PutX@?$St@M@@QEAAMMMM@Z"(ptr {{[^,]*}} %{{.+}}, float noundef [[CONV]], float noundef 1.000000e+00, float noundef [[INC]]) |
| 90 |
++p2->x[idx()][1]; |
| 91 |
// CHECK: call void @"??$foo@H@@YAXHH@Z"(i32 noundef %{{.+}}, i32 noundef %{{.+}}) |
| 92 |
foo(argc, (int)argv[0][0]); |
| 93 |
// CHECK: [[P2:%.+]] = load ptr, ptr % |
| 94 |
// CHECK: [[P1:%.+]] = load ptr, ptr % |
| 95 |
// CHECK: [[P1_X_22_33:%.+]] = call noundef i32 @"?GetX@S@@QEAAHHH@Z"(ptr {{[^,]*}} [[P1]], i32 noundef 22, i32 noundef 33) |
| 96 |
// CHECK: [[CAST:%.+]] = sitofp i32 [[P1_X_22_33]] to double |
| 97 |
// CHECK: [[ARGC:%.+]] = load i32, ptr % |
| 98 |
// CHECK: [[T_X:%.+]] = call noundef i32 @"?get_x@Test1@@QEBAHXZ"(ptr {{[^,]*}} %{{.+}}) |
| 99 |
// CHECK: [[CAST2:%.+]] = trunc i32 [[T_X]] to i8 |
| 100 |
// CHECK: call void @"?PutY@?$St@M@@QEAAXDHN@Z"(ptr {{[^,]*}} [[P2]], i8 noundef [[CAST2]], i32 noundef [[ARGC]], double noundef [[CAST]]) |
| 101 |
p2->y[t.X][argc] = p1->x[22][33]; |
| 102 |
// CHECK: [[P2_1:%.+]] = load ptr, ptr |
| 103 |
// CHECK: [[P2_2:%.+]] = load ptr, ptr |
| 104 |
// CHECK: [[P1:%.+]] = load ptr, ptr |
| 105 |
// CHECK: [[ARGC:%.+]] = load i32, ptr % |
| 106 |
// CHECK: [[P1_X_ARGC_0:%.+]] = call noundef i32 @"?GetX@S@@QEAAHHH@Z"(ptr {{[^,]*}} [[P1]], i32 noundef [[ARGC]], i32 noundef 0) |
| 107 |
// CHECK: [[CAST:%.+]] = trunc i32 [[P1_X_ARGC_0]] to i8 |
| 108 |
// CHECK: [[P2_Y_p1_X_ARGC_0_T:%.+]] = call noundef i8 @"?GetY@?$St@M@@QEAADDVTest1@@@Z"(ptr {{[^,]*}} [[P2_2]], i8 noundef [[CAST]], ptr dead_on_return noundef %{{.+}}) |
| 109 |
// CHECK: [[CAST:%.+]] = sitofp i8 [[P2_Y_p1_X_ARGC_0_T]] to float |
| 110 |
// CHECK: [[J:%.+]] = load i32, ptr % |
| 111 |
// CHECK: [[CAST1:%.+]] = sitofp i32 [[J]] to float |
| 112 |
// CHECK: [[J:%.+]] = load i32, ptr % |
| 113 |
// CHECK: [[CAST2:%.+]] = sitofp i32 [[J]] to float |
| 114 |
// CHECK: call noundef float @"?PutX@?$St@M@@QEAAMMMM@Z"(ptr {{[^,]*}} [[P2_1]], float noundef [[CAST2]], float noundef [[CAST1]], float noundef [[CAST]]) |
| 115 |
p2->x[j][j] = p2->y[p1->x[argc][0]][t]; |
| 116 |
// CHECK: [[CALL:%.+]] = call noundef ptr @"?GetTest1@Test1@@SAPEAV1@XZ"() |
| 117 |
// CHECK-NEXT: call noundef i32 @"?get_x@Test1@@QEBAHXZ"(ptr {{[^,]*}} [[CALL]]) |
| 118 |
return Test1::GetTest1()->X; |
| 119 |
} |
| 120 |
|
| 121 |
// CHECK: define linkonce_odr dso_local void @"??$foo@H@@YAXHH@Z"(i32 noundef %{{.+}}, i32 noundef %{{.+}}) |
| 122 |
// CHECK: call noundef i32 @"?GetX@?$St@H@@QEAAHHH@Z"(ptr {{[^,]*}} [[BAR:%.+]], i32 noundef %{{.+}} i32 noundef %{{.+}}) |
| 123 |
// CHECK: call noundef i32 @"?PutX@?$St@H@@QEAAHHHH@Z"(ptr {{[^,]*}} [[BAR]], i32 noundef %{{.+}}, i32 noundef %{{.+}}, i32 noundef %{{.+}}) |
| 124 |
// CHECK: call noundef i32 @"?GetX@?$St@H@@QEAAHHH@Z"(ptr {{[^,]*}} [[BAR]], i32 noundef %{{.+}} i32 noundef %{{.+}}) |
| 125 |
// CHECK: call void @"?PutY@?$St@H@@QEAAXDHN@Z"(ptr {{[^,]*}} [[BAR]], i8 noundef %{{.+}}, i32 noundef %{{.+}}, double noundef %{{.+}} |
| 126 |
// CHECK: call noundef i32 @"?GetX@?$St@H@@QEAAHHH@Z"(ptr {{[^,]*}} [[BAR]], i32 noundef %{{.+}} i32 noundef %{{.+}}) |
| 127 |
// CHECK: call noundef i8 @"?GetY@?$St@H@@QEAADDVTest1@@@Z"(ptr {{[^,]*}} [[BAR]], i8 noundef %{{.+}}, ptr dead_on_return noundef %{{.+}}) |
| 128 |
// CHECK: call noundef i32 @"?PutX@?$St@H@@QEAAHHHH@Z"(ptr {{[^,]*}} [[BAR]], i32 noundef %{{.+}}, i32 noundef %{{.+}}, i32 noundef %{{.+}}) |
| 129 |
#endif //HEADER |