1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++98
3 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++11
8 #if __cplusplus >= 201103L
9 // expected-note@+2 4 {{declared here}}
11 bool foobool(int argc) {
15 struct S1; // expected-note {{declared here}}
17 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
18 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
19 #pragma omp target teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
20 for (int i = ST; i < N; i++)
21 argv[0][i] = argv[0][i] - argv[0][i-ST];
23 #pragma omp target teams distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
24 for (int i = ST; i < N; i++)
26 argv[0][i] = argv[0][i] - argv[0][i-ST];
27 #pragma omp target teams distribute parallel for collapse () // expected-error {{expected expression}}
28 for (int i = ST; i < N; i++)
29 argv[0][i] = argv[0][i] - argv[0][i-ST];
31 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
32 // expected-error@+2 2 {{expression is not an integral constant expression}}
33 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
34 #pragma omp target teams distribute parallel for collapse (argc
35 for (int i = ST; i < N; i++)
36 argv[0][i] = argv[0][i] - argv[0][i-ST];
38 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
39 #pragma omp target teams distribute parallel for collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
40 for (int i = ST; i < N; i++)
41 argv[0][i] = argv[0][i] - argv[0][i-ST];
43 #pragma omp target teams distribute parallel for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
44 for (int i = ST; i < N; i++)
45 argv[0][i] = argv[0][i] - argv[0][i-ST];
47 #pragma omp target teams distribute parallel for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
48 for (int i = ST; i < N; i++)
49 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target teams distribute parallel for', but found only 1}}
51 #if __cplusplus >= 201103L
52 // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used}}
54 // expected-error@+3 2 {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'collapse' clause}}
55 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
56 // expected-error@+1 2 {{expression is not an integral constant expression}}
57 #pragma omp target teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
58 for (int i = ST; i < N; i++)
59 argv[0][i] = argv[0][i] - argv[0][i-ST];
61 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
62 for (int i = ST; i < N; i++)
63 argv[0][i] = argv[0][i] - argv[0][i-ST];
65 #if __cplusplus >= 201103L
66 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type}}
68 // expected-error@+2 2 {{expression is not an integral constant expression}}
70 #pragma omp target teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
71 for (int i = ST; i < N; i++)
72 argv[0][i] = argv[0][i] - argv[0][i-ST];
74 #pragma omp target teams distribute parallel for collapse (1)
75 for (int i = ST; i < N; i++)
76 argv[0][i] = argv[0][i] - argv[0][i-ST];
78 #pragma omp target teams distribute parallel for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
79 for (T i = ST; i < N; i++)
80 argv[0][i] = argv[0][i] - argv[0][i-ST];
82 #pragma omp target teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
83 foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute parallel for'}}
87 int main(int argc, char **argv) {
88 #pragma omp target teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
89 for (int i = 4; i < 12; i++)
90 argv[0][i] = argv[0][i] - argv[0][i-4];
92 #pragma omp target teams distribute parallel for collapse ( // expected-error {{expected expression}} 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];
96 #pragma omp target teams distribute parallel for collapse () // expected-error {{expected expression}}
97 for (int i = 4; i < 12; i++)
98 argv[0][i] = argv[0][i] - argv[0][i-4];
100 #pragma omp target teams distribute parallel for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
101 for (int i = 4; i < 12; i++)
102 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for', but found only 1}}
104 #pragma omp target teams distribute parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}}
105 for (int i = 4; i < 12; i++)
106 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute parallel for', but found only 1}}
108 #if __cplusplus >= 201103L
109 // expected-note@+2 {{non-constexpr function 'foobool' cannot be used}}
111 #pragma omp target teams distribute parallel for collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
112 for (int i = 4; i < 12; i++)
113 argv[0][i] = argv[0][i] - argv[0][i-4];
115 #if __cplusplus >= 201103L
116 // expected-note@+5 {{non-constexpr function 'foobool' cannot be used}}
118 // expected-error@+3 {{expression is not an integral constant expression}}
119 // expected-error@+2 2 {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'collapse' clause}}
120 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
121 #pragma omp target teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
122 for (int i = 4; i < 12; i++)
123 argv[0][i] = argv[0][i] - argv[0][i-4];
125 #pragma omp target teams distribute parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}}
126 for (int i = 4; i < 12; i++)
127 argv[0][i] = argv[0][i] - argv[0][i-4];
129 #if __cplusplus >= 201103L
130 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type}}
132 // expected-error@+2 {{expression is not an integral constant expression}}
134 #pragma omp target teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
135 for (int i = 4; i < 12; i++)
136 argv[0][i] = argv[0][i] - argv[0][i-4];
138 // expected-error@+3 {{statement after '#pragma omp target teams distribute parallel for' must be a for loop}}
139 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
140 #pragma omp target teams distribute parallel for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
143 #pragma omp target teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
144 foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute parallel for'}}
146 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
147 return tmain<int, char, 1, 0>(argc, argv);