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) { //expected-note 2 {{declared here}}
14 #pragma omp target parallel for ordered
15 for (int i = ST; i < N; i++)
16 argv[0][i] = argv[0][i] - argv[0][i - ST];
17 #pragma omp target parallel for ordered( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
18 for (int i = ST; i < N; i++)
19 argv[0][i] = argv[0][i] - argv[0][i - ST];
20 #pragma omp target parallel for ordered() // expected-error {{expected expression}}
21 for (int i = ST; i < N; i++)
22 argv[0][i] = argv[0][i] - argv[0][i - ST];
23 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
24 // expected-error@+2 2 {{expression is not an integral constant expression}}
25 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
26 #pragma omp target parallel for ordered(argc
27 for (int i = ST; i < N; i++)
28 argv[0][i] = argv[0][i] - argv[0][i - ST];
29 // expected-error@+1 2 {{argument to 'ordered' clause must be a strictly positive integer value}}
30 #pragma omp target parallel for ordered(ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
31 for (int i = ST; i < N; i++)
32 argv[0][i] = argv[0][i] - argv[0][i - ST];
33 #pragma omp target parallel for ordered(1)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
34 for (int i = ST; i < N; i++)
35 argv[0][i] = argv[0][i] - argv[0][i - ST];
36 #pragma omp target parallel for ordered((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'ordered' clause}}
37 for (int i = ST; i < N; i++)
38 argv[0][i] = argv[0][i] - argv[0][i - ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target parallel for', but found only 1}}
39 // expected-error@+3 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}}
40 // expected-error@+2 2 {{argument to 'ordered' clause must be a strictly positive integer value}}
41 // expected-error@+1 2 {{expression is not an integral constant expression}}
42 #pragma omp target parallel for ordered(foobool(argc)), ordered(true), ordered(-5)
43 for (int i = ST; i < N; i++)
44 argv[0][i] = argv[0][i] - argv[0][i - ST];
45 #pragma omp target parallel for ordered(S) // expected-error {{'S' does not refer to a value}}
46 for (int i = ST; i < N; i++)
47 argv[0][i] = argv[0][i] - argv[0][i - ST];
48 // expected-error@+1 2 {{expression is not an integral constant expression}}
49 #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
50 for (int i = ST; i < N; i++)
51 argv[0][i] = argv[0][i] - argv[0][i - ST];
52 #pragma omp target parallel for ordered(1)
53 for (int i = ST; i < N; i++)
54 argv[0][i] = argv[0][i] - argv[0][i - ST];
55 #pragma omp target parallel for ordered(N) // expected-error {{argument to 'ordered' clause must be a strictly positive integer value}}
56 for (T i = ST; i < N; i++)
57 argv[0][i] = argv[0][i] - argv[0][i - ST];
58 #pragma omp target parallel for ordered(2) // expected-note {{as specified in 'ordered' clause}}
59 foo(); // expected-error {{expected 2 for loops after '#pragma omp target parallel for'}}
60 return argc;
61 }
62
main(int argc,char ** argv)63 int main(int argc, char **argv) {
64 #pragma omp target parallel for ordered
65 for (int i = 4; i < 12; i++)
66 argv[0][i] = argv[0][i] - argv[0][i - 4];
67 #pragma omp target parallel for ordered( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68 for (int i = 4; i < 12; i++)
69 argv[0][i] = argv[0][i] - argv[0][i - 4];
70 #pragma omp target parallel for ordered() // expected-error {{expected expression}}
71 for (int i = 4; i < 12; i++)
72 argv[0][i] = argv[0][i] - argv[0][i - 4];
73 #pragma omp target parallel for ordered(4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'ordered' clause}}
74 for (int i = 4; i < 12; i++)
75 argv[0][i] = argv[0][i] - argv[0][i - 4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}}
76 #pragma omp target parallel for ordered(2 + 2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} expected-note {{as specified in 'ordered' clause}}
77 for (int i = 4; i < 12; i++)
78 argv[0][i] = argv[0][i] - argv[0][i - 4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}}
79 #pragma omp target parallel for ordered(foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
80 for (int i = 4; i < 12; i++)
81 argv[0][i] = argv[0][i] - argv[0][i - 4];
82 // expected-error@+3 {{expression is not an integral constant expression}}
83 // expected-error@+2 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}}
84 // expected-error@+1 2 {{argument to 'ordered' clause must be a strictly positive integer value}}
85 #pragma omp target parallel for ordered(foobool(argc)), ordered(true), ordered(-5)
86 for (int i = 4; i < 12; i++)
87 argv[0][i] = argv[0][i] - argv[0][i - 4];
88 #pragma omp target parallel for ordered(S1) // expected-error {{'S1' does not refer to a value}}
89 for (int i = 4; i < 12; i++)
90 argv[0][i] = argv[0][i] - argv[0][i - 4];
91 // expected-error@+1 {{expression is not an integral constant expression}}
92 #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (int i = 4; i < 12; i++)
94 argv[0][i] = argv[0][i] - argv[0][i - 4];
95 // expected-error@+3 {{statement after '#pragma omp target parallel for' must be a for loop}}
96 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
97 #pragma omp target parallel for ordered(ordered(tmain < int, char, -1, -2 > (argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
98 foo();
99 #pragma omp target parallel for ordered(2) // expected-note {{as specified in 'ordered' clause}}
100 foo(); // expected-error {{expected 2 for loops after '#pragma omp target parallel for'}}
101 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
102 return tmain<int, char, 1, 0>(argc, argv);
103 }
104
105