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 |
4 | |
5 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
6 | // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++98 |
7 | // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++11 |
8 | |
9 | void foo() { |
10 | } |
11 | |
12 | #if __cplusplus >= 201103L |
13 | // expected-note@+2 4 {{declared here}} |
14 | #endif |
15 | bool foobool(int argc) { |
16 | return argc; |
17 | } |
18 | |
19 | struct S1; // expected-note {{declared here}} |
20 | |
21 | template <class T, typename S, int N, int ST> // expected-note {{declared here}} |
22 | T tmain(T argc, S **argv) { //expected-note 2 {{declared here}} |
23 | #pragma omp target |
24 | #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}} |
25 | for (int i = ST; i < N; i++) |
26 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
27 | |
28 | #pragma omp target |
29 | #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
30 | for (int i = ST; i < N; i++) |
31 | |
32 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
33 | #pragma omp target |
34 | #pragma omp teams distribute collapse () // expected-error {{expected expression}} |
35 | for (int i = ST; i < N; i++) |
36 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
37 | |
38 | // expected-error@+4 {{expected ')'}} expected-note@+4 {{to match this '('}} |
39 | // expected-error@+3 2 {{expression is not an integral constant expression}} |
40 | // expected-note@+2 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} |
41 | #pragma omp target |
42 | #pragma omp teams distribute collapse (argc |
43 | for (int i = ST; i < N; i++) |
44 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
45 | |
46 | // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
47 | #pragma omp target |
48 | #pragma omp teams distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}} |
49 | for (int i = ST; i < N; i++) |
50 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
51 | |
52 | #pragma omp target |
53 | #pragma omp teams distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} |
54 | for (int i = ST; i < N; i++) |
55 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
56 | |
57 | #pragma omp target |
58 | #pragma omp teams distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} |
59 | for (int i = ST; i < N; i++) |
60 | argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute', but found only 1}} |
61 | |
62 | #if __cplusplus >= 201103L |
63 | // expected-note@+6 2 {{non-constexpr function 'foobool' cannot be used}} |
64 | #endif |
65 | // expected-error@+4 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}} |
66 | // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
67 | // expected-error@+2 2 {{expression is not an integral constant expression}} |
68 | #pragma omp target |
69 | #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) |
70 | for (int i = ST; i < N; i++) |
71 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
72 | |
73 | #pragma omp target |
74 | #pragma omp teams distribute collapse (S) // expected-error {{'S' does not refer to a value}} |
75 | for (int i = ST; i < N; i++) |
76 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
77 | |
78 | #if __cplusplus >= 201103L |
79 | // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}} |
80 | #else |
81 | // expected-error@+3 2 {{expression is not an integral constant expression}} |
82 | #endif |
83 | #pragma omp target |
84 | #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
85 | for (int i = ST; i < N; i++) |
86 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
87 | |
88 | #pragma omp target |
89 | #pragma omp teams distribute collapse (1) |
90 | for (int i = ST; i < N; i++) |
91 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
92 | |
93 | #pragma omp target |
94 | #pragma omp teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}} |
95 | for (T i = ST; i < N; i++) |
96 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
97 | |
98 | #pragma omp target |
99 | #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} |
100 | foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}} |
101 | return argc; |
102 | } |
103 | |
104 | int main(int argc, char **argv) { |
105 | #pragma omp target |
106 | #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}} |
107 | for (int i = 4; i < 12; i++) |
108 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
109 | |
110 | #pragma omp target |
111 | #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
112 | for (int i = 4; i < 12; i++) |
113 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
114 | |
115 | #pragma omp target |
116 | #pragma omp teams distribute collapse () // expected-error {{expected expression}} |
117 | for (int i = 4; i < 12; i++) |
118 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
119 | |
120 | #pragma omp target |
121 | #pragma omp teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}} |
122 | for (int i = 4; i < 12; i++) |
123 | argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}} |
124 | |
125 | #pragma omp target |
126 | #pragma omp teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} expected-note {{as specified in 'collapse' clause}} |
127 | for (int i = 4; i < 12; i++) |
128 | argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}} |
129 | |
130 | #if __cplusplus >= 201103L |
131 | // expected-note@+3 {{non-constexpr function 'foobool' cannot be used}} |
132 | #endif |
133 | #pragma omp target |
134 | #pragma omp teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} |
135 | for (int i = 4; i < 12; i++) |
136 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
137 | |
138 | #if __cplusplus >= 201103L |
139 | // expected-note@+6 {{non-constexpr function 'foobool' cannot be used}} |
140 | #endif |
141 | // expected-error@+4 {{expression is not an integral constant expression}} |
142 | // expected-error@+3 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}} |
143 | // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
144 | #pragma omp target |
145 | #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) |
146 | for (int i = 4; i < 12; i++) |
147 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
148 | |
149 | #pragma omp target |
150 | #pragma omp teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} |
151 | for (int i = 4; i < 12; i++) |
152 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
153 | |
154 | #if __cplusplus >= 201103L |
155 | // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}} |
156 | #else |
157 | // expected-error@+3 {{expression is not an integral constant expression}} |
158 | #endif |
159 | #pragma omp target |
160 | #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
161 | for (int i = 4; i < 12; i++) |
162 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
163 | |
164 | // expected-error@+4 {{statement after '#pragma omp teams distribute' must be a for loop}} |
165 | // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} |
166 | #pragma omp target |
167 | #pragma omp teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} |
168 | foo(); |
169 | |
170 | #pragma omp target |
171 | #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} |
172 | foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}} |
173 | |
174 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}} |
175 | return tmain<int, char, 1, 0>(argc, argv); |
176 | } |
177 | |
178 | |