[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / parallel_for_simd_messages.cpp
blobb3408fab4417f822fe7dd295fd6f14dcbcd589dd
1 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
5 void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp parallel for simd
8 for (int i = 0; i < 10; ++i)
9 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
12 void foo() {
15 #pragma omp parallel for simd // expected-error {{unexpected OpenMP directive '#pragma omp parallel for simd'}}
17 int main(int argc, char **argv) {
18 #pragma omp parallel for simd { // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
19 for (int i = 0; i < argc; ++i)
20 foo();
21 #pragma omp parallel for simd ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
22 for (int i = 0; i < argc; ++i)
23 foo();
24 #pragma omp parallel for simd[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
25 for (int i = 0; i < argc; ++i)
26 foo();
27 #pragma omp parallel for simd] // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
28 for (int i = 0; i < argc; ++i)
29 foo();
30 #pragma omp parallel for simd) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
31 for (int i = 0; i < argc; ++i)
32 foo();
33 #pragma omp parallel for simd } // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
34 for (int i = 0; i < argc; ++i)
35 foo();
36 #pragma omp parallel for simd
37 for (int i = 0; i < argc; ++i)
38 foo();
39 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
40 #pragma omp parallel for simd unknown()
41 for (int i = 0; i < argc; ++i)
42 foo();
43 L1:
44 for (int i = 0; i < argc; ++i)
45 foo();
46 #pragma omp parallel for simd
47 for (int i = 0; i < argc; ++i)
48 foo();
49 #pragma omp parallel for simd
50 for (int i = 0; i < argc; ++i) {
51 goto L1; // expected-error {{use of undeclared label 'L1'}}
52 argc++;
55 for (int i = 0; i < 10; ++i) {
56 switch (argc) {
57 case (0):
58 #pragma omp parallel for simd
59 for (int i = 0; i < argc; ++i) {
60 foo();
61 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
62 continue;
64 default:
65 break;
68 #pragma omp parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
69 for (int i = 0; i < 10; ++i)
70 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
72 goto L2; // expected-error {{use of undeclared label 'L2'}}
73 #pragma omp parallel for simd
74 for (int i = 0; i < argc; ++i)
75 L2:
76 foo();
77 #pragma omp parallel for simd
78 for (int i = 0; i < argc; ++i) {
79 return 1; // expected-error {{cannot return from OpenMP region}}
82 [[]] // expected-error {{an attribute list cannot appear here}}
83 #pragma omp parallel for simd
84 for (int n = 0; n < 100; ++n) {
87 return 0;
90 void test_ordered() {
91 #pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
92 for (int i = 0; i < 16; ++i)
94 #pragma omp parallel for simd ordered
95 for (int i = 0; i < 16; ++i)
97 // expected-error@+1 {{'ordered' clause with a parameter cannot be specified in '#pragma omp parallel for simd' directive}}
98 #pragma omp parallel for simd ordered(1)
99 for (int i = 0; i < 16; ++i)