[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_simd_simdlen_messages.cpp
blobf84dd17f9fb060f5c124622ce1d51594971737c1
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) {
23 #pragma omp target teams distribute simd safelen // expected-error {{expected '(' after 'safelen'}}
24 for (int i = ST; i < N; i++)
25 argv[0][i] = argv[0][i] - argv[0][i-ST];
27 #pragma omp target teams distribute simd safelen ( // 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];
31 #pragma omp target teams distribute simd safelen () // expected-error {{expected expression}}
32 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
34 #pragma omp target teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
35 for (int i = ST; i < N; i++)
36 argv[0][i] = argv[0][i] - argv[0][i-ST];
38 #pragma omp target teams distribute simd safelen (ST // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}} expected-error {{expected ')'}} expected-note {{to match this '('}}
39 for (int i = ST; i < N; i++)
40 argv[0][i] = argv[0][i] - argv[0][i-ST];
42 #pragma omp target teams distribute simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
43 for (int i = ST; i < N; i++)
44 argv[0][i] = argv[0][i] - argv[0][i-ST];
46 #pragma omp target teams distribute simd safelen ((ST > 0) ? 1 + ST : 2)
47 for (int i = ST; i < N; i++)
48 argv[0][i] = argv[0][i] - argv[0][i-ST];
50 // expected-error@+3 2 {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'safelen' clause}}
51 // expected-error@+2 {{argument to 'safelen' clause must be a strictly positive integer value}}
52 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
53 #pragma omp target teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5)
54 for (int i = ST; i < N; i++)
55 argv[0][i] = argv[0][i] - argv[0][i-ST];
57 #pragma omp target teams distribute simd safelen (S) // expected-error {{'S' does not refer to a value}}
58 for (int i = ST; i < N; i++)
59 argv[0][i] = argv[0][i] - argv[0][i-ST];
61 #if __cplusplus <= 199711L
62 // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
63 #else
64 // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
65 #endif
66 #pragma omp target teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
67 for (int i = ST; i < N; i++)
68 argv[0][i] = argv[0][i] - argv[0][i-ST];
70 #pragma omp target teams distribute simd safelen (4)
71 for (int i = ST; i < N; i++)
72 argv[0][i] = argv[0][i] - argv[0][i-ST];
74 #pragma omp target teams distribute simd safelen (N) // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}}
75 for (T i = ST; i < N; i++)
76 argv[0][i] = argv[0][i] - argv[0][i-ST];
78 return argc;
81 int main(int argc, char **argv) {
82 #pragma omp target teams distribute simd safelen // expected-error {{expected '(' after 'safelen'}}
83 for (int i = 4; i < 12; i++)
84 argv[0][i] = argv[0][i] - argv[0][i-4];
86 #pragma omp target teams distribute simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87 for (int i = 4; i < 12; i++)
88 argv[0][i] = argv[0][i] - argv[0][i-4];
90 #pragma omp target teams distribute simd safelen () // expected-error {{expected expression}}
91 for (int i = 4; i < 12; i++)
92 argv[0][i] = argv[0][i] - argv[0][i-4];
94 #pragma omp target teams distribute simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int i = 4; i < 12; i++)
96 argv[0][i] = argv[0][i] - argv[0][i-4];
98 #pragma omp target teams distribute simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
99 for (int i = 4; i < 12; i++)
100 argv[0][i] = argv[0][i] - argv[0][i-4];
103 #pragma omp target teams distribute simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
104 for (int i = 4; i < 12; i++)
105 argv[0][i] = argv[0][i] - argv[0][i-4];
107 // expected-error@+3 {{argument to 'safelen' clause must be a strictly positive integer value}}
108 // expected-error@+2 2 {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'safelen' clause}}
109 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
110 #pragma omp target teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5)
111 for (int i = 4; i < 12; i++)
112 argv[0][i] = argv[0][i] - argv[0][i-4];
114 #pragma omp target teams distribute simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
115 for (int i = 4; i < 12; i++)
116 argv[0][i] = argv[0][i] - argv[0][i-4];
118 #if __cplusplus <= 199711L
119 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
120 #else
121 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
122 #endif
123 #pragma omp target teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
124 for (int i = 4; i < 12; i++)
125 argv[0][i] = argv[0][i] - argv[0][i-4];
127 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
128 #pragma omp target teams distribute simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
129 foo(); // expected-error {{statement after '#pragma omp target teams distribute simd' must be a for loop}}
131 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
132 return tmain<int, char, 12, 4>(argc, argv);