[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_simd_safelen_messages.cpp
blob3cf70dbdc9efd509248b8e5b18c2272d4433b1f9
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
24 #pragma omp teams distribute simd safelen // expected-error {{expected '(' after 'safelen'}}
25 for (int i = ST; i < N; i++)
26 argv[0][i] = argv[0][i] - argv[0][i-ST];
28 #pragma omp target
29 #pragma omp teams distribute simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
30 for (int i = ST; i < N; i++)
31 argv[0][i] = argv[0][i] - argv[0][i-ST];
33 #pragma omp target
34 #pragma omp teams distribute simd safelen () // expected-error {{expected expression}}
35 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37 #pragma omp target
38 #pragma omp teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
39 for (int i = ST; i < N; i++)
40 argv[0][i] = argv[0][i] - argv[0][i-ST];
42 #pragma omp target
43 #pragma omp 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 '('}}
44 for (int i = ST; i < N; i++)
45 argv[0][i] = argv[0][i] - argv[0][i-ST];
47 #pragma omp target
48 #pragma omp teams distribute simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
49 for (int i = ST; i < N; i++)
50 argv[0][i] = argv[0][i] - argv[0][i-ST];
52 #pragma omp target
53 #pragma omp teams distribute simd safelen ((ST > 0) ? 1 + ST : 2)
54 for (int i = ST; i < N; i++)
55 argv[0][i] = argv[0][i] - argv[0][i-ST];
57 #pragma omp target
58 // expected-error@+3 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'safelen' clause}}
59 // expected-error@+2 {{argument to 'safelen' clause must be a strictly positive integer value}}
60 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
61 #pragma omp teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5)
62 for (int i = ST; i < N; i++)
63 argv[0][i] = argv[0][i] - argv[0][i-ST];
65 #pragma omp target
66 #pragma omp teams distribute simd safelen (S) // expected-error {{'S' does not refer to a value}}
67 for (int i = ST; i < N; i++)
68 argv[0][i] = argv[0][i] - argv[0][i-ST];
70 #if __cplusplus <= 199711L
71 // expected-error@+5 2 {{integral constant expression}} expected-note@+5 0+{{constant expression}}
72 #else
73 // expected-error@+3 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
74 #endif
75 #pragma omp target
76 #pragma omp teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
77 for (int i = ST; i < N; i++)
78 argv[0][i] = argv[0][i] - argv[0][i-ST];
80 #pragma omp target
81 #pragma omp teams distribute simd safelen (4)
82 for (int i = ST; i < N; i++)
83 argv[0][i] = argv[0][i] - argv[0][i-ST];
85 #pragma omp target
86 #pragma omp teams distribute simd safelen (N) // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}}
87 for (T i = ST; i < N; i++)
88 argv[0][i] = argv[0][i] - argv[0][i-ST];
90 return argc;
93 int main(int argc, char **argv) {
94 #pragma omp target
95 #pragma omp teams distribute simd safelen // expected-error {{expected '(' after 'safelen'}}
96 for (int i = 4; i < 12; i++)
97 argv[0][i] = argv[0][i] - argv[0][i-4];
99 #pragma omp target
100 #pragma omp teams distribute simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
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 simd safelen () // expected-error {{expected expression}}
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 simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
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 simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
116 for (int i = 4; i < 12; i++)
117 argv[0][i] = argv[0][i] - argv[0][i-4];
120 #pragma omp target
121 #pragma omp teams distribute simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
122 for (int i = 4; i < 12; i++)
123 argv[0][i] = argv[0][i] - argv[0][i-4];
125 #pragma omp target
126 // expected-error@+3 {{argument to 'safelen' clause must be a strictly positive integer value}}
127 // expected-error@+2 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'safelen' clause}}
128 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
129 #pragma omp teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5)
130 for (int i = 4; i < 12; i++)
131 argv[0][i] = argv[0][i] - argv[0][i-4];
133 #pragma omp target
134 #pragma omp teams distribute simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
135 for (int i = 4; i < 12; i++)
136 argv[0][i] = argv[0][i] - argv[0][i-4];
138 #if __cplusplus <= 199711L
139 // expected-error@+5 {{integral constant expression}} expected-note@+5 0+{{constant expression}}
140 #else
141 // expected-error@+3 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
142 #endif
143 #pragma omp target
144 #pragma omp teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
145 for (int i = 4; i < 12; i++)
146 argv[0][i] = argv[0][i] - argv[0][i-4];
148 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
149 #pragma omp target
150 #pragma omp teams distribute simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
151 foo(); // expected-error {{statement after '#pragma omp teams distribute simd' must be a for loop}}
153 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
154 return tmain<int, char, 12, 4>(argc, argv);