[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / parallel_for_messages.cpp
blob10836a7ca25aa320da135116d9f0371a61ee13a2
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
9 void xxx(int argc) {
10 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
11 #pragma omp parallel for
12 for(int i = 0; i < 10; ++i)
13 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
16 void foo() {
19 #pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
21 int main(int argc, char **argv) {
22 #pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
23 for (int i = 0; i < argc; ++i)
24 foo();
25 #pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
26 for (int i = 0; i < argc; ++i)
27 foo();
28 #pragma omp parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
29 for (int i = 0; i < argc; ++i)
30 foo();
31 #pragma omp parallel for] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
32 for (int i = 0; i < argc; ++i)
33 foo();
34 #pragma omp parallel for) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
38 for (int i = 0; i < argc; ++i)
39 foo();
40 #pragma omp parallel for
41 for (int i = 0; i < argc; ++i)
42 foo();
43 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
44 #pragma omp parallel for unknown()
45 for (int i = 0; i < argc; ++i)
46 foo();
47 L1:
48 for (int i = 0; i < argc; ++i)
49 foo();
50 #pragma omp parallel for
51 for (int i = 0; i < argc; ++i)
52 foo();
53 #pragma omp parallel for
54 for (int i = 0; i < argc; ++i) {
55 goto L1; // expected-error {{use of undeclared label 'L1'}}
56 argc++;
59 for (int i = 0; i < 10; ++i) {
60 switch (argc) {
61 case (0):
62 #pragma omp parallel for
63 for (int i = 0; i < argc; ++i) {
64 foo();
65 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
66 continue;
68 default:
69 break;
72 #pragma omp parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
73 for (int i = 0; i < 10; ++i)
74 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
76 goto L2; // expected-error {{use of undeclared label 'L2'}}
77 #pragma omp parallel for
78 for (int i = 0; i < argc; ++i)
79 L2:
80 foo();
81 #pragma omp parallel for
82 for (int i = 0; i < argc; ++i) {
83 return 1; // expected-error {{cannot return from OpenMP region}}
86 [[]] // expected-error {{an attribute list cannot appear here}}
87 #pragma omp parallel for
88 for (int n = 0; n < 100; ++n) {
91 return 0;
94 void test_ordered() {
95 #pragma omp parallel for ordered ordered // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'ordered' clause}}
96 for (int i = 0; i < 16; ++i)
98 #pragma omp parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} expected-error {{expected '(' after 'order'}}
99 for (int i = 0; i < 10; ++i)
101 #pragma omp parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
102 for (int i = 0; i < 10; ++i)
104 #pragma omp parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
105 for (int i = 0; i < 10; ++i)
107 #pragma omp parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
108 for (int i = 0; i < 10; ++i)
110 #pragma omp parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}}
111 for (int i = 0; i < 10; ++i)
113 #pragma omp parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
114 for (int i = 0; i < 10; ++i)
116 #pragma omp parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
117 for (int i = 0; i < 10; ++i)
119 #pragma omp parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
120 for (int i = 0; i < 10; ++i)
122 #pragma omp parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
123 for (int i = 0; i < 10; ++i)
125 #pragma omp parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for'}} omp51-error {{directive '#pragma omp parallel for' cannot contain more than one 'order' clause}}
126 for (int i = 0; i < 10; ++i)