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