Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / task_shared_messages.cpp
blob309d56b423f8c2e09fff7080ce8810044e441b0b
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, z;
67 int &j = i;
68 #pragma omp task shared // expected-error {{expected '(' after 'shared'}}
69 foo();
70 #pragma omp task shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 foo();
72 #pragma omp task shared() // expected-error {{expected expression}}
73 foo();
74 #pragma omp task shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
75 foo();
76 #pragma omp task shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 foo();
78 #pragma omp task shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
79 foo();
80 #pragma omp task shared(argc, z)
81 foo();
82 #pragma omp task shared(S1) // expected-error {{'S1' does not refer to a value}}
83 foo();
84 #pragma omp task shared(a, b, c, d, f)
85 foo();
86 #pragma omp task shared(argv[1]) // expected-error {{expected variable name}}
87 foo();
88 #pragma omp task shared(ba)
89 foo();
90 #pragma omp task shared(ca)
91 foo();
92 #pragma omp task shared(da)
93 foo();
94 #pragma omp task shared(e, g)
95 foo();
96 #pragma omp task shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
97 foo();
98 #pragma omp task private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
99 foo();
100 #pragma omp task firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
101 foo();
102 #pragma omp parallel private(i)
103 #pragma omp task shared(i)
104 #pragma omp task shared(j)
105 foo();
106 #pragma omp parallel firstprivate(i)
107 #pragma omp task shared(i)
108 #pragma omp task shared(j)
109 foo();
111 return 0;