• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RxUN: %clang_cc1 -verify -fopenmp -std=c++11 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4 // expected-no-diagnostics
5 
6 #ifndef HEADER
7 #define HEADER
8 
9 struct ST {
10   int *a;
11 };
12 struct SA {
13   int i, j;
14   int *k = &j;
15   int *&z = k;
funcSA16   void func(int arg) {
17 #pragma omp target data map(tofrom: i) use_device_ptr(k)
18     {}
19 #pragma omp target data map(tofrom: i) use_device_ptr(z)
20     {}
21   return;
22  }
23 };
24 // CHECK: struct SA
25 // CHECK: void func(
26 // CHECK: #pragma omp target data map(tofrom: this->i) use_device_ptr(this->k)
27 // CHECK: #pragma omp target data map(tofrom: this->i) use_device_ptr(this->z)
28 struct SB {
29   unsigned A;
30   unsigned B;
31   float Arr[100];
32   float *Ptr;
fooSB33   float *foo() {
34     return &Arr[0];
35   }
36 };
37 
38 struct SC {
39   unsigned A : 2;
40   unsigned B : 3;
41   unsigned C;
42   unsigned D;
43   float Arr[100];
44   SB S;
45   SB ArrS[100];
46   SB *PtrS;
47   SB *&RPtrS;
48   float *Ptr;
49 
SCSC50   SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
51 };
52 
53 union SD {
54   unsigned A;
55   float B;
56 };
57 
58 struct S1;
59 extern S1 a;
60 class S2 {
61   mutable int a;
62 public:
S2()63   S2():a(0) { }
S2(S2 & s2)64   S2(S2 &s2):a(s2.a) { }
65   static float S2s;
66   static const float S2sc;
67 };
68 const float S2::S2sc = 0;
69 const S2 b;
70 const S2 ba[5];
71 class S3 {
72   int a;
73 public:
S3()74   S3():a(0) { }
S3(S3 & s3)75   S3(S3 &s3):a(s3.a) { }
76 };
77 const S3 c;
78 const S3 ca[5];
79 extern const int f;
80 class S4 {
81   int a;
82   S4();
83   S4(const S4 &s4);
84 public:
S4(int v)85   S4(int v):a(v) { }
86 };
87 class S5 {
88   int a;
S5()89   S5():a(0) {}
S5(const S5 & s5)90   S5(const S5 &s5):a(s5.a) { }
91 public:
S5(int v)92   S5(int v):a(v) { }
93 };
94 
95 S3 h;
96 #pragma omp threadprivate(h)
97 
98 typedef int from;
99 
100 template <typename T>
tmain(T argc)101 T tmain(T argc) {
102   T i;
103   T &j = i;
104   T *k = &j;
105   T *&z = k;
106 #pragma omp target data map(tofrom: i) use_device_ptr(k)
107   {}
108 #pragma omp target data map(tofrom: i) use_device_ptr(z)
109   {}
110   return 0;
111 }
112 
113 // CHECK: template <typename T = int> int tmain(int argc) {
114 // CHECK-NEXT: int i;
115 // CHECK-NEXT: int &j = i;
116 // CHECK-NEXT: int *k = &j;
117 // CHECK-NEXT: int *&z = k;
118 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(k)
119 // CHECK-NEXT: {
120 // CHECK-NEXT: }
121 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(z)
122 
123 // CHECK: template <typename T = int *> int *tmain(int *argc) {
124 // CHECK-NEXT: int *i;
125 // CHECK-NEXT: int *&j = i;
126 // CHECK-NEXT: int **k = &j;
127 // CHECK-NEXT: int **&z = k;
128 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(k)
129 // CHECK-NEXT: {
130 // CHECK-NEXT: }
131 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(z)
132 
133 // CHECK-LABEL: int main(int argc, char **argv) {
main(int argc,char ** argv)134 int main(int argc, char **argv) {
135   int i;
136   int &j = i;
137   int *k = &j;
138   int *&z = k;
139 // CHECK-NEXT: int i;
140 // CHECK-NEXT: int &j = i;
141 // CHECK-NEXT: int *k = &j;
142 // CHECK-NEXT: int *&z = k;
143 #pragma omp target data map(tofrom: i) use_device_ptr(k)
144 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(k)
145   {}
146 // CHECK-NEXT: {
147 // CHECK-NEXT: }
148 #pragma omp target data map(tofrom: i) use_device_ptr(z)
149 // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(z)
150   {}
151   return tmain<int>(argc) + (*tmain<int*>(&argc));
152 }
153 
154 #endif
155