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 parallel for simd 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 target 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 '('}}
17   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
18   #pragma omp target parallel for simd 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 target parallel for simd 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 target 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 '('}}
23   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
24   #pragma omp target parallel for simd schedule (auto,  // 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 target parallel for simd schedule (runtime, 3)  // 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   // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
29   #pragma omp target parallel for simd schedule (guided argc
30   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
31   // expected-error@+1 2 {{argument to 'schedule' clause must be a strictly positive integer value}}
32   #pragma omp target parallel for simd schedule (static, ST // 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 parallel for simd schedule (dynamic, 1)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
35   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
36   #pragma omp target parallel for simd schedule (guided, (ST > 0) ? 1 + ST : 2)
37   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
38   // expected-error@+2 2 {{directive '#pragma omp target parallel for simd' cannot contain more than one 'schedule' clause}}
39   // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
40   #pragma omp target parallel for simd schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
41   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
42   #pragma omp target parallel for simd schedule (static, S) // expected-error {{'S' does not refer to a value}}
43   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44   // expected-error@+1 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
45   #pragma omp target parallel for simd schedule (guided, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
46   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
47   #pragma omp target parallel for simd schedule (dynamic, 1)
48   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
49   #pragma omp target parallel for simd schedule (static, N) // expected-error {{argument to 'schedule' clause must be a strictly positive integer value}}
50   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
51   return argc;
52 }
53 
main(int argc,char ** argv)54 int main(int argc, char **argv) {
55   #pragma omp target parallel for simd schedule // expected-error {{expected '(' after 'schedule'}}
56   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
57   #pragma omp target 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 '('}}
58   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
59   #pragma omp target parallel for simd schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto', 'runtime', 'monotonic', 'nonmonotonic' or 'simd' in OpenMP clause 'schedule'}}
60   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
61   #pragma omp target parallel for simd schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
62   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
63   #pragma omp target 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 '('}}
64   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
65   #pragma omp target parallel for simd schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
66   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
67   #pragma omp target parallel for simd schedule (runtime, 3)  // expected-error {{expected ')'}} expected-note {{to match this '('}}
68   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69   #pragma omp target parallel for simd schedule (guided, 4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
70   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
71   #pragma omp target parallel for simd schedule (static, 2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
72   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
73   #pragma omp target parallel for simd schedule (dynamic, foobool(1) > 0 ? 1 : 2)
74   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
75   // expected-error@+2 2 {{directive '#pragma omp target parallel for simd' cannot contain more than one 'schedule' clause}}
76   // expected-error@+1 {{argument to 'schedule' clause must be a strictly positive integer value}}
77   #pragma omp target parallel for simd schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
78   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
79   #pragma omp target parallel for simd schedule (guided, S1) // expected-error {{'S1' does not refer to a value}}
80   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
81   // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'char *'}}
82   #pragma omp target parallel for simd schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
83   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
84   // expected-error@+3 {{statement after '#pragma omp target parallel for simd' must be a for loop}}
85   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
86   #pragma omp target parallel for simd schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
87   foo();
88   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
89   return tmain<int, char, 1, 0>(argc, argv);
90 }
91 
92