1 // RUN: %clang_cc1 -verify -fopenmp %s
2 
foo()3 void foo() {
4 }
5 
foobool(int argc)6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}}
11 
12 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
tmain(T argc,S ** argv)13 T tmain(T argc, S **argv) {
14   #pragma omp for schedule // expected-error {{expected '(' after 'schedule'}}
15   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
16   #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 '('}}
17   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
18   #pragma omp for schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
19   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
20   #pragma omp for schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
21   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
22   #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 '('}}
23   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
24   #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 '('}}
25   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
26   #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 '('}}
27   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28   #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 '('}}
29   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30   #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 '('}}
31   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
32   #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 '('}}
33   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34   #pragma omp for schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
35   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
36   #pragma omp for schedule (runtime, 3)  // 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   // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
39   #pragma omp for schedule (guided argc
40   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
41   // expected-error@+1 2 {{argument to 'schedule' clause must be a strictly positive integer value}}
42   #pragma omp for schedule (static, ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
43   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44   #pragma omp for schedule (dynamic, 1)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}}
45   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46   #pragma omp for schedule (guided, (ST > 0) ? 1 + ST : 2)
47   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
48   // expected-error@+2 2 {{directive '#pragma omp for' cannot contain more than one 'schedule' clause}}
49   // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
50   #pragma omp for schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
51   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
52   #pragma omp for schedule (static, S) // expected-error {{'S' does not refer to a value}}
53   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
54   // expected-error@+1 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
55   #pragma omp for schedule (guided, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
56   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
57   #pragma omp for schedule (dynamic, 1)
58   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
59   #pragma omp for schedule (static, N) // expected-error {{argument to 'schedule' clause must be a strictly positive integer value}}
60   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
61   #pragma omp for schedule (nonmonotonic: static) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
62   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
63   #pragma omp for schedule (nonmonotonic: auto) // 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: runtime) // 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 (monotonic, nonmonotonic: auto) // expected-error {{modifier 'nonmonotonic' cannot be used along with modifier 'monotonic'}}
68   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
69   #pragma omp for schedule (nonmonotonic, monotonic: auto) // expected-error {{modifier 'monotonic' cannot be used along with modifier 'nonmonotonic'}}
70   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
71   #pragma omp for schedule (nonmonotonic, nonmonotonic: auto) // expected-error {{modifier 'nonmonotonic' 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 (monotonic, monotonic: auto) // expected-error {{modifier 'monotonic' cannot be used along with modifier 'monotonic'}}
74   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
75   #pragma omp for schedule (nonmonotonic: guided) ordered // expected-error {{'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified}}
76   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
77   #pragma omp for ordered(1) schedule(nonmonotonic: dynamic) // 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   return argc;
80 }
81 
main(int argc,char ** argv)82 int main(int argc, char **argv) {
83   #pragma omp for schedule // expected-error {{expected '(' after 'schedule'}}
84   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
85   #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 '('}}
86   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
87   #pragma omp for schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
88   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
89   #pragma omp for schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
90   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
91   #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 '('}}
92   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
93   #pragma omp for schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
94   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
95   #pragma omp for schedule (runtime, 3)  // 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 (guided, 4 // 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 (static, 2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}}
100   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
101   #pragma omp for schedule (dynamic, foobool(1) > 0 ? 1 : 2)
102   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
103   // expected-error@+2 2 {{directive '#pragma omp for' cannot contain more than one 'schedule' clause}}
104   // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
105   #pragma omp for schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
106   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
107   #pragma omp for schedule (guided, S1) // expected-error {{'S1' does not refer to a value}}
108   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
109   // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'char *'}}
110   #pragma omp for schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
111   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
112   // expected-error@+3 {{statement after '#pragma omp for' must be a for loop}}
113   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
114   #pragma omp for schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
115   foo();
116   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
117   return tmain<int, char, 1, 0>(argc, argv);
118 }
119 
120