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