[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / ms-property.cpp
blobd33dbf0a0ded63c88253109e010f476d5b7cb5ff
1 // RUN: %clang_cc1 -ast-print -verify -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 -triple=x86_64-pc-win32 -fms-compatibility -include-pch %t -verify %s -ast-print -o - | FileCheck %s
4 // expected-no-diagnostics
6 #ifndef HEADER
7 #define HEADER
9 class Test1 {
10 private:
11 int x_;
13 public:
14 Test1(int x) : x_(x) {}
15 __declspec(property(get = get_x)) int X;
16 int get_x() const { return x_; }
17 static Test1 *GetTest1() { return new Test1(10); }
20 class S {
21 public:
22 __declspec(property(get=GetX,put=PutX)) int x[];
23 int GetX(int i, int j) { return i+j; }
24 void PutX(int i, int j, int k) { j = i = k; }
27 template <typename T>
28 class St {
29 public:
30 __declspec(property(get=GetX,put=PutX)) T x[];
31 T GetX(T i, T j) { return i+j; }
32 T PutX(T i, T j, T k) { return j = i = k; }
33 ~St() { x[0][0] = x[1][1]; }
36 // CHECK: this->x[0][0] = this->x[1][1];
37 // CHECK: this->x[0][0] = this->x[1][1];
39 // CHECK-LABEL: main
40 int main(int argc, char **argv) {
41 S *p1 = 0;
42 St<float> *p2 = 0;
43 // CHECK: St<int> a;
44 St<int> a;
45 // CHECK-NEXT: int j = (p1->x)[223][11];
46 int j = (p1->x)[223][11];
47 // CHECK-NEXT: (p1->x[23])[1] = j;
48 (p1->x[23])[1] = j;
49 // CHECK-NEXT: float j1 = (p2->x[223][11]);
50 float j1 = (p2->x[223][11]);
51 // CHECK-NEXT: ((p2->x)[23])[1] = j1;
52 ((p2->x)[23])[1] = j1;
53 // CHECK-NEXT: ++(((p2->x)[23])[1]);
54 ++(((p2->x)[23])[1]);
55 // CHECK-NEXT: j1 = ((p2->x)[23])[1] = j1;
56 j1 = ((p2->x)[23])[1] = j1;
57 // CHECK-NEXT: return Test1::GetTest1()->X;
58 return Test1::GetTest1()->X;
60 #endif // HEADER