• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -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 
foo()9 void foo() {}
10 
11 template <typename T, int C>
tmain(T argc,T * argv)12 T tmain(T argc, T *argv) {
13   T i, j, a[20];
14 #pragma omp target
15   foo();
16 #pragma omp target if (target:argc > 0)
17   foo();
18 #pragma omp target if (C)
19   foo();
20 #pragma omp target map(i)
21   foo();
22 #pragma omp target map(a[0:10], i)
23   foo();
24 #pragma omp target map(to: i) map(from: j)
25   foo();
26 #pragma omp target map(always,alloc: i)
27   foo();
28 #pragma omp target nowait
29   foo();
30 #pragma omp target depend(in : argc, argv[i:argc], a[:])
31   foo();
32 #pragma omp target defaultmap(tofrom: scalar)
33   foo();
34   return 0;
35 }
36 
37 // CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
38 // CHECK-NEXT: int i, j, a[20]
39 // CHECK-NEXT: #pragma omp target
40 // CHECK-NEXT: foo();
41 // CHECK-NEXT: #pragma omp target if(target: argc > 0)
42 // CHECK-NEXT: foo()
43 // CHECK-NEXT: #pragma omp target if(5)
44 // CHECK-NEXT: foo()
45 // CHECK-NEXT: #pragma omp target map(tofrom: i)
46 // CHECK-NEXT: foo()
47 // CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
48 // CHECK-NEXT: foo()
49 // CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
50 // CHECK-NEXT: foo()
51 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
52 // CHECK-NEXT: foo()
53 // CHECK-NEXT: #pragma omp target nowait
54 // CHECK-NEXT: foo()
55 // CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
56 // CHECK-NEXT: foo()
57 // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
58 // CHECK-NEXT: foo()
59 // CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) {
60 // CHECK-NEXT: char i, j, a[20]
61 // CHECK-NEXT: #pragma omp target
62 // CHECK-NEXT: foo();
63 // CHECK-NEXT: #pragma omp target if(target: argc > 0)
64 // CHECK-NEXT: foo()
65 // CHECK-NEXT: #pragma omp target if(1)
66 // CHECK-NEXT: foo()
67 // CHECK-NEXT: #pragma omp target map(tofrom: i)
68 // CHECK-NEXT: foo()
69 // CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
70 // CHECK-NEXT: foo()
71 // CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
72 // CHECK-NEXT: foo()
73 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
74 // CHECK-NEXT: foo()
75 // CHECK-NEXT: #pragma omp target nowait
76 // CHECK-NEXT: foo()
77 // CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
78 // CHECK-NEXT: foo()
79 // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
80 // CHECK-NEXT: foo()
81 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
82 // CHECK-NEXT: T i, j, a[20]
83 // CHECK-NEXT: #pragma omp target
84 // CHECK-NEXT: foo();
85 // CHECK-NEXT: #pragma omp target if(target: argc > 0)
86 // CHECK-NEXT: foo()
87 // CHECK-NEXT: #pragma omp target if(C)
88 // CHECK-NEXT: foo()
89 // CHECK-NEXT: #pragma omp target map(tofrom: i)
90 // CHECK-NEXT: foo()
91 // CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
92 // CHECK-NEXT: foo()
93 // CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
94 // CHECK-NEXT: foo()
95 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
96 // CHECK-NEXT: foo()
97 // CHECK-NEXT: #pragma omp target nowait
98 // CHECK-NEXT: foo()
99 // CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
100 // CHECK-NEXT: foo()
101 // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
102 // CHECK-NEXT: foo()
103 
104 // CHECK-LABEL: int main(int argc, char **argv) {
main(int argc,char ** argv)105 int main (int argc, char **argv) {
106   int i, j, a[20];
107 // CHECK-NEXT: int i, j, a[20]
108 #pragma omp target
109 // CHECK-NEXT: #pragma omp target
110   foo();
111 // CHECK-NEXT: foo();
112 #pragma omp target if (argc > 0)
113 // CHECK-NEXT: #pragma omp target if(argc > 0)
114   foo();
115 // CHECK-NEXT: foo();
116 
117 #pragma omp target map(i) if(argc>0)
118 // CHECK-NEXT: #pragma omp target map(tofrom: i) if(argc > 0)
119   foo();
120 // CHECK-NEXT: foo();
121 
122 #pragma omp target map(i)
123 // CHECK-NEXT: #pragma omp target map(tofrom: i)
124   foo();
125 // CHECK-NEXT: foo();
126 
127 #pragma omp target map(a[0:10], i)
128 // CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
129   foo();
130 // CHECK-NEXT: foo();
131 
132 #pragma omp target map(to: i) map(from: j)
133 // CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
134   foo();
135 // CHECK-NEXT: foo();
136 
137 #pragma omp target map(always,alloc: i)
138 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
139   foo();
140 // CHECK-NEXT: foo();
141 
142 #pragma omp target nowait
143 // CHECK-NEXT: #pragma omp target nowait
144   foo();
145 // CHECK-NEXT: foo();
146 
147 #pragma omp target depend(in : argc, argv[i:argc], a[:])
148 // CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
149   foo();
150 // CHECK-NEXT: foo();
151 
152 #pragma omp target defaultmap(tofrom: scalar)
153 // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
154   foo();
155 // CHECK-NEXT: foo();
156 
157   return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
158 }
159 
160 #endif
161