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