[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_simd_collapse_messages.cpp
blob63132be20c9b70b6b7fa7b06ecf2f5f08b258d65
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++98 -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++11 -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++98 -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++11 -Wuninitialized
9 // expected-note@* 0+{{declared here}}
11 void foo() {
14 bool foobool(int argc) {
15 return argc;
18 struct S1;
20 template <class T, typename S, int N, int ST>
21 T tmain(T argc, S **argv) {
22 #pragma omp target
23 #pragma omp 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];
27 #pragma omp target
28 #pragma omp teams distribute parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i = ST; i < N; i++)
30 argv[0][i] = argv[0][i] - argv[0][i-ST];
32 #pragma omp target
33 #pragma omp teams distribute parallel for simd collapse () // expected-error {{expected expression}}
34 for (int i = ST; i < N; i++)
35 argv[0][i] = argv[0][i] - argv[0][i-ST];
37 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
38 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
39 #pragma omp target
40 #pragma omp teams distribute parallel for simd collapse (argc
41 for (int i = ST; i < N; i++)
42 argv[0][i] = argv[0][i] - argv[0][i-ST];
44 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
45 #pragma omp target
46 #pragma omp teams distribute parallel for simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
47 for (int i = ST; i < N; i++)
48 argv[0][i] = argv[0][i] - argv[0][i-ST];
50 #pragma omp target
51 #pragma omp teams distribute parallel for simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
52 for (int i = ST; i < N; i++)
53 argv[0][i] = argv[0][i] - argv[0][i-ST];
55 #pragma omp target
56 #pragma omp teams distribute parallel for simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
57 for (int i = ST; i < N; i++)
58 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}}
60 // expected-error@+4 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'collapse' clause}}
61 // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
62 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
63 #pragma omp target
64 #pragma omp teams distribute parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5)
65 for (int i = ST; i < N; i++)
66 argv[0][i] = argv[0][i] - argv[0][i-ST];
68 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
69 for (int i = ST; i < N; i++)
70 argv[0][i] = argv[0][i] - argv[0][i-ST];
72 #if __cplusplus >= 201103L
73 // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}}
74 #else
75 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
76 #endif
77 #pragma omp target
78 #pragma omp teams distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
79 for (int i = ST; i < N; i++)
80 argv[0][i] = argv[0][i] - argv[0][i-ST];
82 #pragma omp target
83 #pragma omp teams distribute parallel for simd collapse (1)
84 for (int i = ST; i < N; i++)
85 argv[0][i] = argv[0][i] - argv[0][i-ST];
87 #pragma omp target
88 #pragma omp teams distribute parallel for simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
89 for (T i = ST; i < N; i++)
90 argv[0][i] = argv[0][i] - argv[0][i-ST];
92 #pragma omp target
93 #pragma omp teams distribute parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
94 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for simd'}}
95 return argc;
98 int main(int argc, char **argv) {
99 #pragma omp target
100 #pragma omp teams distribute parallel for simd collapse // expected-error {{expected '(' after 'collapse'}}
101 for (int i = 4; i < 12; i++)
102 argv[0][i] = argv[0][i] - argv[0][i-4];
104 #pragma omp target
105 #pragma omp teams distribute parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
106 for (int i = 4; i < 12; i++)
107 argv[0][i] = argv[0][i] - argv[0][i-4];
109 #pragma omp target
110 #pragma omp teams distribute parallel for simd collapse () // expected-error {{expected expression}}
111 for (int i = 4; i < 12; i++)
112 argv[0][i] = argv[0][i] - argv[0][i-4];
114 #pragma omp target
115 #pragma omp teams distribute parallel for simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
116 for (int i = 4; i < 12; i++)
117 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}}
119 #pragma omp target
120 #pragma omp teams distribute parallel for simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
121 for (int i = 4; i < 12; i++)
122 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}}
124 #pragma omp target
125 #pragma omp teams distribute parallel for simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
126 for (int i = 4; i < 12; i++)
127 argv[0][i] = argv[0][i] - argv[0][i-4];
129 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
130 // expected-error@+3 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'collapse' clause}}
131 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
132 #pragma omp target
133 #pragma omp teams distribute parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5)
134 for (int i = 4; i < 12; i++)
135 argv[0][i] = argv[0][i] - argv[0][i-4];
137 #pragma omp target
138 #pragma omp teams distribute parallel for simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
139 for (int i = 4; i < 12; i++)
140 argv[0][i] = argv[0][i] - argv[0][i-4];
142 #if __cplusplus >= 201103L
143 // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}}
144 #else
145 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
146 #endif
147 #pragma omp target
148 #pragma omp teams distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
149 for (int i = 4; i < 12; i++)
150 argv[0][i] = argv[0][i] - argv[0][i-4];
152 // expected-error@+4 {{statement after '#pragma omp teams distribute parallel for simd' must be a for loop}}
153 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
154 #pragma omp target
155 #pragma omp teams distribute parallel for simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
156 foo();
158 #pragma omp target
159 #pragma omp teams distribute parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
160 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for simd'}}
162 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
163 return tmain<int, char, 1, 0>(argc, argv);