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 |
4 | |
5 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
6 | // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s |
7 | // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s |
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 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 collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
28 | for (int i = ST; i < N; i++) |
29 | |
30 | argv[0][i] = argv[0][i] - argv[0][i-ST]; |
31 | #pragma omp target teams distribute 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 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 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 collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' 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 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', but found only 1}} |
54 | |
55 | #if __cplusplus >= 201103L |
56 | // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
57 | #endif |
58 | // expected-error@+3 2 {{directive '#pragma omp target teams distribute' 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 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 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 <= 199711L |
70 | // expected-error@+4 2 {{expression is not an integral constant expression}} |
71 | #else |
72 | // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} |
73 | #endif |
74 | #pragma omp target teams distribute 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 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 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 collapse (2) // expected-note {{as specified in 'collapse' clause}} |
87 | foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}} |
88 | return argc; |
89 | } |
90 | |
91 | int main(int argc, char **argv) { |
92 | #pragma omp target teams distribute 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 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 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 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', but found only 1}} |
107 | |
108 | #pragma omp target teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' 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', but found only 1}} |
111 | |
112 | // expected-error@+4 {{expression is not an integral constant expression}} |
113 | #if __cplusplus >= 201103L |
114 | // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
115 | #endif |
116 | #pragma omp target teams distribute collapse (foobool(1) > 0 ? 1 : 2) |
117 | for (int i = 4; i < 12; i++) |
118 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
119 | |
120 | #if __cplusplus >= 201103L |
121 | // expected-note@+5{{non-constexpr function 'foobool' cannot be used in a constant expression}} |
122 | #endif |
123 | // expected-error@+3 {{expression is not an integral constant expression}} |
124 | // expected-error@+2 2 {{directive '#pragma omp target teams distribute' cannot contain more than one 'collapse' clause}} |
125 | // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
126 | #pragma omp target teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) |
127 | for (int i = 4; i < 12; i++) |
128 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
129 | |
130 | #pragma omp target teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} |
131 | for (int i = 4; i < 12; i++) |
132 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
133 | |
134 | #if __cplusplus <= 199711L |
135 | // expected-error@+4 {{expression is not an integral constant expression}} |
136 | #else |
137 | // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} |
138 | #endif |
139 | #pragma omp target teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
140 | for (int i = 4; i < 12; i++) |
141 | argv[0][i] = argv[0][i] - argv[0][i-4]; |
142 | |
143 | // expected-error@+3 {{statement after '#pragma omp target teams distribute' must be a for loop}} |
144 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} |
145 | #pragma omp target teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} |
146 | foo(); |
147 | |
148 | #pragma omp target teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} |
149 | foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}} |
150 | |
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); |
153 | } |
154 | |
155 | |