blob: f4b5b3a26d643200c2bd3696e9762bc41b5e9fa9 [file] [log] [blame]
Alexey Bataevdb390212015-05-20 04:24:19 +00001// RUN: %clang_cc1 -verify -fopenmp %s
Alexey Bataev56dafe82014-06-20 07:16:17 +00002
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd %s
4
Alexey Bataev56dafe82014-06-20 07:16:17 +00005void foo() {
6}
7
8bool foobool(int argc) {
9 return argc;
10}
11
12struct S1; // expected-note {{declared here}}
13
14template <class T, typename S, int N, int ST> // expected-note {{declared here}}
15T tmain(T argc, S **argv) {
16 #pragma omp for schedule // expected-error {{expected '(' after 'schedule'}}
17 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev6402bca2015-12-28 07:25:51 +000018 #pragma omp for schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000019 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev6402bca2015-12-28 07:25:51 +000020 #pragma omp for schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000021 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
22 #pragma omp for schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
23 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev6402bca2015-12-28 07:25:51 +000024 #pragma omp for schedule (monotonic // expected-error {{expected ')'}} expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-warning {{missing ':' after schedule modifier - ignoring}} expected-note {{to match this '('}}
25 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
26 #pragma omp for schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
27 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28 #pragma omp for schedule (nonmonotonic, // expected-error {{expected ')'}} expected-error {{expected 'simd' in OpenMP clause 'schedule'}} expected-warning {{missing ':' after schedule modifier - ignoring}} expected-note {{to match this '('}}
29 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30 #pragma omp for schedule (simd: // expected-error {{expected ')'}} expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-note {{to match this '('}}
31 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
32 #pragma omp for schedule (monotonic, auto // expected-error {{expected ')'}} expected-warning {{missing ':' after schedule modifier - ignoring}} expected-error {{expected 'simd' in OpenMP clause 'schedule'}} expected-note {{to match this '('}}
33 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34 #pragma omp for schedule (nonmonotonic: auto, // expected-error {{expected ')'}} expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}} expected-note {{to match this '('}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000035 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
36 #pragma omp for schedule (auto, // expected-error {{expected ')'}} expected-note {{to match this '('}}
37 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
38 #pragma omp for schedule (runtime, 3) // expected-error {{expected ')'}} expected-note {{to match this '('}}
39 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
40 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
41 #pragma omp for schedule (guided argc
42 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataeva0569352015-12-01 10:17:31 +000043 // expected-error@+1 2 {{argument to 'schedule' clause must be a strictly positive integer value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000044 #pragma omp for schedule (static, ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
45 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46 #pragma omp for schedule (dynamic, 1)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}}
47 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
48 #pragma omp for schedule (guided, (ST > 0) ? 1 + ST : 2)
49 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
50 // expected-error@+2 2 {{directive '#pragma omp for' cannot contain more than one 'schedule' clause}}
Alexey Bataeva0569352015-12-01 10:17:31 +000051 // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000052 #pragma omp for schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
53 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev6b8046a2015-09-03 07:23:48 +000054 #pragma omp for schedule (static, S) // expected-error {{'S' does not refer to a value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000055 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
56 // expected-error@+1 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
57 #pragma omp for schedule (guided, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
58 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
59 #pragma omp for schedule (dynamic, 1)
60 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataeva0569352015-12-01 10:17:31 +000061 #pragma omp for schedule (static, N) // expected-error {{argument to 'schedule' clause must be a strictly positive integer value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000062 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev6402bca2015-12-28 07:25:51 +000063 #pragma omp for schedule (nonmonotonic: static) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
64 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
65 #pragma omp for schedule (nonmonotonic: auto) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
66 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
67 #pragma omp for schedule (nonmonotonic: runtime) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
68 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
69 #pragma omp for schedule (monotonic, nonmonotonic: auto) // expected-error {{modifier 'nonmonotonic' cannot be used along with modifier 'monotonic'}}
70 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
71 #pragma omp for schedule (nonmonotonic, monotonic: auto) // expected-error {{modifier 'monotonic' cannot be used along with modifier 'nonmonotonic'}}
72 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
73 #pragma omp for schedule (nonmonotonic, nonmonotonic: auto) // expected-error {{modifier 'nonmonotonic' cannot be used along with modifier 'nonmonotonic'}}
74 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
75 #pragma omp for schedule (monotonic, monotonic: auto) // expected-error {{modifier 'monotonic' cannot be used along with modifier 'monotonic'}}
76 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
77 #pragma omp for schedule (nonmonotonic: guided) ordered // expected-error {{'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified}}
78 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
79 #pragma omp for ordered(1) schedule(nonmonotonic: dynamic) // expected-error {{'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified}}
80 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
Alexey Bataev56dafe82014-06-20 07:16:17 +000081 return argc;
82}
83
84int main(int argc, char **argv) {
85 #pragma omp for schedule // expected-error {{expected '(' after 'schedule'}}
86 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
Alexey Bataev6402bca2015-12-28 07:25:51 +000087 #pragma omp for schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000088 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
Alexey Bataev6402bca2015-12-28 07:25:51 +000089 #pragma omp for schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000090 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
91 #pragma omp for schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
Alexey Bataev6402bca2015-12-28 07:25:51 +000093 #pragma omp for schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataev56dafe82014-06-20 07:16:17 +000094 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
95 #pragma omp for schedule (auto, // expected-error {{expected ')'}} expected-note {{to match this '('}}
96 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
97 #pragma omp for schedule (runtime, 3) // expected-error {{expected ')'}} expected-note {{to match this '('}}
98 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
99 #pragma omp for schedule (guided, 4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
100 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
101 #pragma omp for schedule (static, 2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}}
102 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
103 #pragma omp for schedule (dynamic, foobool(1) > 0 ? 1 : 2)
104 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
105 // expected-error@+2 2 {{directive '#pragma omp for' cannot contain more than one 'schedule' clause}}
Alexey Bataeva0569352015-12-01 10:17:31 +0000106 // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +0000107 #pragma omp for schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
108 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
Alexey Bataev6b8046a2015-09-03 07:23:48 +0000109 #pragma omp for schedule (guided, S1) // expected-error {{'S1' does not refer to a value}}
Alexey Bataev56dafe82014-06-20 07:16:17 +0000110 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
111 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'char *'}}
112 #pragma omp for schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
113 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
114 // expected-error@+3 {{statement after '#pragma omp for' must be a for loop}}
115 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
Alexey Bataev6b8046a2015-09-03 07:23:48 +0000116 #pragma omp for schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
Alexey Bataev56dafe82014-06-20 07:16:17 +0000117 foo();
118 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
119 return tmain<int, char, 1, 0>(argc, argv);
120}
121