1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
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}}
21 #pragma omp distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
22 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25 #pragma omp distribute parallel for collapse ( // expected-error {{expected expression}} 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];
29 #pragma omp distribute parallel for collapse () // expected-error {{expected expression}}
30 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
33 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
34 // expected-error@+2 2 {{expression is not an integral constant expression}}
35 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
36 #pragma omp distribute parallel for collapse (argc
37 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
40 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41 #pragma omp distribute parallel for collapse (ST // 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];
45 #pragma omp distribute parallel for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
46 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
49 #pragma omp distribute parallel for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
50 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute parallel for', but found only 1}}
51 // expected-error@+8 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}
52 // expected-error@+7 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
53 // expected-error@+6 2 {{expression is not an integral constant expression}}
54 #if __cplusplus >= 201103L
55 // expected-note@+4 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
59 #pragma omp distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
60 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
63 #pragma omp distribute parallel for collapse (S) // expected-error {{'S' does not refer to a value}}
64 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
65 #if __cplusplus <= 199711L
66 // expected-error@+6 2 {{expression is not an integral constant expression}}
68 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
72 #pragma omp distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
73 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
76 #pragma omp distribute parallel for collapse (1)
77 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
80 #pragma omp distribute parallel for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
81 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
84 #pragma omp distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
85 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for'}}
89 int main(int argc, char **argv) {
92 #pragma omp distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
93 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
96 #pragma omp distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
100 #pragma omp distribute parallel for collapse () // expected-error {{expected expression}}
101 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
104 #pragma omp distribute parallel for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
105 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute parallel for', but found only 1}}
108 #pragma omp distribute parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}}
109 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute parallel for', but found only 1}}
110 // expected-error@+6 {{expression is not an integral constant expression}}
111 #if __cplusplus >= 201103L
112 // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
116 #pragma omp distribute parallel for collapse (foobool(1) > 0 ? 1 : 2)
117 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
118 // expected-error@+8 {{expression is not an integral constant expression}}
119 #if __cplusplus >= 201103L
120 // expected-note@+6{{non-constexpr function 'foobool' cannot be used in a constant expression}}
122 // expected-error@+4 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}
123 // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
126 #pragma omp distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
127 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
130 #pragma omp distribute parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}}
131 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
132 #if __cplusplus <= 199711L
133 // expected-error@+6 {{expression is not an integral constant expression}}
135 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
139 #pragma omp distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
140 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
141 // expected-error@+5 {{statement after '#pragma omp distribute parallel for' must be a for loop}}
142 // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
145 #pragma omp distribute parallel for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
149 #pragma omp distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
150 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for'}}
151 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
152 return tmain<int, char, 1, 0>(argc, argv);