[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_simd_collapse_messages.cpp
blob500980fbd2c4b14a0f9e855ae013bee745f88b1a
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -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 teams distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
23 for (int i = ST; i < N; i++)
24 argv[0][i] = argv[0][i] - argv[0][i-ST];
26 #pragma omp target teams distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
27 for (int i = ST; i < N; i++)
29 argv[0][i] = argv[0][i] - argv[0][i-ST];
30 #pragma omp target teams distribute simd collapse () // expected-error {{expected expression}}
31 for (int i = ST; i < N; i++)
32 argv[0][i] = argv[0][i] - argv[0][i-ST];
34 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
35 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
36 #pragma omp target teams distribute simd collapse (argc
37 for (int i = ST; i < N; i++)
38 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 target teams distribute simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
42 for (int i = ST; i < N; i++)
43 argv[0][i] = argv[0][i] - argv[0][i-ST];
45 #pragma omp target teams distribute simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
46 for (int i = ST; i < N; i++)
47 argv[0][i] = argv[0][i] - argv[0][i-ST];
49 #pragma omp target teams distribute simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
50 for (int i = ST; i < N; i++)
51 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target teams distribute simd', but found only 1}}
53 // expected-error@+3 2 {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'collapse' clause}}
54 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
55 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
56 #pragma omp target teams distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
57 for (int i = ST; i < N; i++)
58 argv[0][i] = argv[0][i] - argv[0][i-ST];
60 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
61 for (int i = ST; i < N; i++)
62 argv[0][i] = argv[0][i] - argv[0][i-ST];
64 #if __cplusplus <= 199711L
65 // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
66 #else
67 // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
68 #endif
69 #pragma omp target teams distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
70 for (int i = ST; i < N; i++)
71 argv[0][i] = argv[0][i] - argv[0][i-ST];
73 #pragma omp target teams distribute simd collapse (1)
74 for (int i = ST; i < N; i++)
75 argv[0][i] = argv[0][i] - argv[0][i-ST];
77 #pragma omp target teams distribute simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
78 for (T i = ST; i < N; i++)
79 argv[0][i] = argv[0][i] - argv[0][i-ST];
81 #pragma omp target teams distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
82 foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute simd'}}
83 return argc;
86 int main(int argc, char **argv) {
87 #pragma omp target teams distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
88 for (int i = 4; i < 12; i++)
89 argv[0][i] = argv[0][i] - argv[0][i-4];
91 #pragma omp target teams distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (int i = 4; i < 12; i++)
93 argv[0][i] = argv[0][i] - argv[0][i-4];
95 #pragma omp target teams distribute simd collapse () // expected-error {{expected expression}}
96 for (int i = 4; i < 12; i++)
97 argv[0][i] = argv[0][i] - argv[0][i-4];
99 #pragma omp target teams distribute simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
100 for (int i = 4; i < 12; i++)
101 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
103 #pragma omp target teams distribute simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
104 for (int i = 4; i < 12; i++)
105 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
107 #pragma omp target teams distribute simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
108 for (int i = 4; i < 12; i++)
109 argv[0][i] = argv[0][i] - argv[0][i-4];
111 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
112 // expected-error@+2 2 {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'collapse' clause}}
113 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
114 #pragma omp target teams distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
115 for (int i = 4; i < 12; i++)
116 argv[0][i] = argv[0][i] - argv[0][i-4];
118 #pragma omp target teams distribute simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
119 for (int i = 4; i < 12; i++)
120 argv[0][i] = argv[0][i] - argv[0][i-4];
122 #if __cplusplus >= 201103L
123 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
124 #else
125 // expected-error@+2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
126 #endif
127 #pragma omp target teams distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
128 for (int i = 4; i < 12; i++)
129 argv[0][i] = argv[0][i] - argv[0][i-4];
131 // expected-error@+3 {{statement after '#pragma omp target teams distribute simd' must be a for loop}}
132 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
133 #pragma omp target teams distribute simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
134 foo();
136 #pragma omp target teams distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
137 foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute simd'}}
139 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
140 return tmain<int, char, 1, 0>(argc, argv);