[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / parallel_sections_messages.cpp
blob06182802d7a986418d742b4d7c82facc2883d59b
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -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 sections
9 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
13 void foo() {
16 #pragma omp parallel sections // expected-error {{unexpected OpenMP directive '#pragma omp parallel sections'}}
18 int main(int argc, char **argv) {
19 #pragma omp parallel sections {// expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
21 foo();
23 #pragma omp parallel sections( // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
25 foo();
27 #pragma omp parallel sections[ // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
29 foo();
31 #pragma omp parallel sections] // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
33 foo();
35 #pragma omp parallel sections) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
37 foo();
39 #pragma omp parallel sections } // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
41 foo();
43 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
44 #pragma omp parallel sections unknown()
46 foo();
47 #pragma omp section
48 L1:
49 foo();
51 #pragma omp parallel sections
55 #pragma omp parallel sections
57 goto L1; // expected-error {{use of undeclared label 'L1'}}
60 for (int i = 0; i < 10; ++i) {
61 switch (argc) {
62 case (0):
63 #pragma omp parallel sections
65 foo();
66 break; // expected-error {{'break' statement not in loop or switch statement}}
67 continue; // expected-error {{'continue' statement not in loop statement}}
69 default:
70 break;
73 #pragma omp parallel sections default(none) // expected-note {{explicit data sharing attribute requested here}}
75 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
78 goto L2; // expected-error {{use of undeclared label 'L2'}}
79 #pragma omp parallel sections
81 L2:
82 foo();
84 #pragma omp parallel sections
86 return 1; // expected-error {{cannot return from OpenMP region}}
89 [[]] // expected-error {{an attribute list cannot appear here}}
90 #pragma omp parallel sections
94 return 0;