]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / OpenMP / teams_distribute_parallel_for_schedule_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
4
5 void foo() {
6 }
7
8 bool foobool(int argc) {
9   return argc;
10 }
11
12 struct S1; // expected-note {{declared here}}
13
14 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
15 T tmain(T argc, S **argv) {
16 // expected-error@+2 {{expected '(' after 'schedule'}}
17 #pragma omp target
18 #pragma omp teams distribute parallel for schedule
19   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
20
21 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
22 #pragma omp target
23 #pragma omp teams distribute parallel for schedule (
24   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25
26 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
27 #pragma omp target
28 #pragma omp teams distribute parallel for schedule ()
29   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30
31 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
32 #pragma omp target
33 #pragma omp teams distribute parallel for schedule (auto
34   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
35
36 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
37 #pragma omp target
38 #pragma omp teams distribute parallel for schedule (auto_dynamic
39   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
40
41 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
42 #pragma omp target
43 #pragma omp teams distribute parallel for schedule (auto,
44   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
45
46 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
47 #pragma omp target
48 #pragma omp teams distribute parallel for schedule (runtime, 3)
49   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
50
51 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
52 #pragma omp target
53 #pragma omp teams distribute parallel for schedule (guided argc
54   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
55
56 // expected-error@+2 2 {{argument to 'schedule' clause must be a strictly positive integer value}}
57 #pragma omp target
58 #pragma omp teams distribute parallel for schedule (static, ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
60
61 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
62 #pragma omp target
63 #pragma omp teams distribute parallel for schedule (dynamic, 1))
64   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
65
66 #pragma omp target
67 #pragma omp teams distribute parallel for schedule (guided, (ST > 0) ? 1 + ST : 2)
68   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
69
70 // expected-error@+3 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'schedule' clause}}
71 // expected-error@+2 {{argument to 'schedule' clause must be a strictly positive integer value}}
72 #pragma omp target
73 #pragma omp teams distribute parallel for schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
74   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
75
76 // expected-error@+2 {{'S' does not refer to a value}}
77 #pragma omp target
78 #pragma omp teams distribute parallel for schedule (static, S)
79   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
80
81 // expected-error@+3 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
82 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
83 #pragma omp target
84 #pragma omp teams distribute parallel for schedule (guided, argv[1]=2)
85   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
86
87 #pragma omp target
88 #pragma omp teams distribute parallel for schedule (dynamic, 1)
89   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
90
91 // expected-error@+2 {{argument to 'schedule' clause must be a strictly positive integer value}}
92 #pragma omp target
93 #pragma omp teams distribute parallel for schedule (static, N)
94   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
95
96   return argc;
97 }
98
99 int main(int argc, char **argv) {
100 // expected-error@+2 {{expected '(' after 'schedule'}}
101 #pragma omp target
102 #pragma omp teams distribute parallel for schedule
103   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
104
105 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
106 #pragma omp target
107 #pragma omp teams distribute parallel for schedule (
108   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
109
110 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
111 #pragma omp target
112 #pragma omp teams distribute parallel for schedule ()
113   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
114
115 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
116 #pragma omp target
117 #pragma omp teams distribute parallel for schedule (auto
118   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
119
120 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
121 #pragma omp target
122 #pragma omp teams distribute parallel for schedule (auto_dynamic
123   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
124
125 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
126 #pragma omp target
127 #pragma omp teams distribute parallel for schedule (auto,
128   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
129
130 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
131 #pragma omp target
132 #pragma omp teams distribute parallel for schedule (runtime, 3)
133   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
134
135 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
136 #pragma omp target
137 #pragma omp teams distribute parallel for schedule (guided, 4
138   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
139
140 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
141 #pragma omp target
142 #pragma omp teams distribute parallel for schedule (static, 2+2))
143   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
144
145 #pragma omp target
146 #pragma omp teams distribute parallel for schedule (dynamic, foobool(1) > 0 ? 1 : 2)
147   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
148
149 // expected-error@+3 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'schedule' clause}}
150 // expected-error@+2 {{argument to 'schedule' clause must be a strictly positive integer value}}
151 #pragma omp target
152 #pragma omp teams distribute parallel for schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
153   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
154
155 // expected-error@+2 {{'S1' does not refer to a value}}
156 #pragma omp target
157 #pragma omp teams distribute parallel for schedule (guided, S1)
158   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
159
160 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
161 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
162 #pragma omp target
163 #pragma omp teams distribute parallel for schedule (static, argv[1]=2)
164   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
165
166 // expected-error@+4 {{statement after '#pragma omp teams distribute parallel for' must be a for loop}}
167 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
168 #pragma omp target
169 #pragma omp teams distribute parallel for schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
170   foo();
171
172   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
173   return tmain<int, char, 1, 0>(argc, argv);
174 }