xref: /llvm-project/clang/test/SemaCXX/ms-property-new.cpp (revision af0ee617fc5f69051297b0c23f8c818b20f02c3a)
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
5 
6 #ifndef HEADER
7 #define HEADER
8 
9 struct S {
GetXS10   int GetX() { return 42; }
11   __declspec(property(get=GetX)) int x;
12 
GetYS13   int GetY(int i, int j) { return i+j; }
14   __declspec(property(get=GetY)) int y[];
15 
16   void* operator new(__SIZE_TYPE__, int);
17 };
18 
19 template <typename T>
20 struct TS {
GetTTS21   T GetT() { return T(); }
22   __declspec(property(get=GetT)) T t;
23 
GetRTS24   T GetR(T i, T j) { return i+j; }
25   __declspec(property(get=GetR)) T r[];
26 };
27 
main(int argc,char ** argv)28 int main(int argc, char **argv) {
29   // CHECK: S *s;
30   // CHECK-NEXT: new (s->x) S;
31   // CHECK-NEXT: new ((s->y)[1][2]) S;
32   S *s;
33   new (s->x) S;
34   new ((s->y)[1][2]) S;
35 
36   // CHECK-NEXT: TS<double> *ts;
37   // CHECK-NEXT: new (ts->t) S;
38   // CHECK-NEXT: new ((ts->r)[1][2]) S;
39   TS<double> *ts;
40   new (ts->t) S;
41   new ((ts->r)[1][2]) S;
42 }
43 
44 #endif
45