[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / parallel_masked_shared_messages.cpp
blob5e4f1ecdd2728729fc232f0d529bb1f012e2dd4d
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
5 void foo() {
8 bool foobool(int argc) {
9 return argc;
12 struct S1; // expected-note {{declared here}}
13 extern S1 a;
14 class S2 {
15 mutable int a;
17 public:
18 S2() : a(0) {}
19 S2(S2 &s2) : a(s2.a) {}
21 const S2 b;
22 const S2 ba[5];
23 class S3 {
24 int a;
26 public:
27 S3() : a(0) {}
28 S3(S3 &s3) : a(s3.a) {}
30 const S3 c;
31 const S3 ca[5];
32 extern const int f;
33 class S4 {
34 int a;
35 S4();
36 S4(const S4 &s4);
38 public:
39 S4(int v) : a(v) {}
41 class S5 {
42 int a;
43 S5() : a(0) {}
44 S5(const S5 &s5) : a(s5.a) {}
46 public:
47 S5(int v) : a(v) {}
50 S3 h;
51 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
53 namespace A {
54 double x;
55 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
57 namespace B {
58 using A::x;
61 int main(int argc, char **argv) {
62 const int d = 5;
63 const int da[5] = {0};
64 S4 e(4);
65 S5 g(5);
66 int i, k;
67 int &j = i;
68 #pragma omp parallel masked shared // expected-error {{expected '(' after 'shared'}}
69 { foo(); }
70 #pragma omp parallel masked shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 { foo(); }
72 #pragma omp parallel masked shared() // expected-error {{expected expression}}
73 { foo(); }
74 #pragma omp parallel masked shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
75 { foo(); }
76 #pragma omp parallel masked shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 { foo(); }
78 #pragma omp parallel masked shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
79 { foo(); }
80 #pragma omp parallel masked shared(argc)
81 { foo(); }
82 #pragma omp parallel masked shared(S1) // expected-error {{'S1' does not refer to a value}}
83 { foo(); }
84 #pragma omp parallel masked shared(a, b, c, d, f, k)
85 { foo(); }
86 #pragma omp parallel masked shared(argv[1]) // expected-error {{expected variable name}}
87 { foo(); }
88 #pragma omp parallel masked shared(ba)
89 { foo(); }
90 #pragma omp parallel masked shared(ca)
91 { foo(); }
92 #pragma omp parallel masked shared(da)
93 { foo(); }
94 #pragma omp parallel masked shared(e, g)
95 { foo(); }
96 #pragma omp parallel masked shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
97 { foo(); }
98 #pragma omp parallel masked private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
99 { foo(); }
100 #pragma omp parallel masked firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
101 { foo(); }
102 #pragma omp parallel masked private(i)
104 #pragma omp parallel masked shared(i)
106 #pragma omp parallel masked shared(j)
107 { foo(); }
110 #pragma omp parallel masked firstprivate(i)
112 #pragma omp parallel masked shared(i)
114 #pragma omp parallel masked shared(j)
115 { foo(); }
119 return 0;