1 // RUN: %clang_cc1 -verify -fopenmp %s
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
8 bool foobool(int argc) {
12 struct S1; // expected-note {{declared here}}
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'}}
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];
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 '('}}
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];
26 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
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];
31 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
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 '('}}
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];
41 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
46 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
51 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
56 // expected-error@+2 2 {{argument to 'schedule' clause must be a strictly positive integer value}}
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];
61 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
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];
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];
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}}
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];
76 // expected-error@+2 {{'S' does not refer to a value}}
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];
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 '('}}
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];
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];
91 // expected-error@+2 {{argument to 'schedule' clause must be a strictly positive integer value}}
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];
99 int main(int argc, char **argv) {
100 // expected-error@+2 {{expected '(' after 'schedule'}}
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];
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 '('}}
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];
110 // expected-error@+2 {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
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];
115 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
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 '('}}
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];
125 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
130 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
135 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
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];
140 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
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];
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];
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}}
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];
155 // expected-error@+2 {{'S1' does not refer to a value}}
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];
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 *'}}
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];
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}}
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 '('}}
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);