[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_teams_messages.cpp
blobc690d9de82c3ed025915a224b4f823f55c9c0bce
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 target teams
8 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
11 void foo() {
14 #pragma omp target teams // expected-error {{unexpected OpenMP directive '#pragma omp target teams'}}
16 int main(int argc, char **argv) {
17 #pragma omp target teams { // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
18 foo();
19 #pragma omp target teams ( // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
20 foo();
21 #pragma omp target teams [ // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
22 foo();
23 #pragma omp target teams ] // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
24 foo();
25 #pragma omp target teams ) // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
26 foo();
27 #pragma omp target teams } // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
28 foo();
29 #pragma omp target teams
30 foo();
31 #pragma omp target teams unknown() // expected-warning {{extra tokens at the end of '#pragma omp target teams' are ignored}}
32 foo();
33 L1:
34 foo();
35 #pragma omp target teams
37 #pragma omp target teams
39 goto L1; // expected-error {{use of undeclared label 'L1'}}
40 argc++;
43 for (int i = 0; i < 10; ++i) {
44 switch(argc) {
45 case (0):
46 #pragma omp target teams
48 foo();
49 break; // expected-error {{'break' statement not in loop or switch statement}}
50 continue; // expected-error {{'continue' statement not in loop statement}}
52 default:
53 break;
56 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
57 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
59 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
60 #pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
63 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
65 #pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
69 goto L2; // expected-error {{use of undeclared label 'L2'}}
70 #pragma omp target teams
71 L2:
72 foo();
73 #pragma omp target teams
75 return 1; // expected-error {{cannot return from OpenMP region}}
78 [[]] // expected-error {{an attribute list cannot appear here}}
79 #pragma omp target teams
80 for (int n = 0; n < 100; ++n) {}
82 return 0;