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