Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / parallel_shared_messages.cpp
blob0869f169133fe4de7b89625c616ba23e103cfbb4
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;
16 public:
17 S2():a(0) { }
18 S2(S2 &s2):a(s2.a) { }
20 const S2 b;
21 const S2 ba[5];
22 class S3 {
23 int a;
24 public:
25 S3():a(0) { }
26 S3(S3 &s3):a(s3.a) { }
28 const S3 c;
29 const S3 ca[5];
30 extern const int f;
31 class S4 {
32 int a;
33 S4();
34 S4(const S4 &s4);
35 public:
36 S4(int v):a(v) { }
38 class S5 {
39 int a;
40 S5():a(0) {}
41 S5(const S5 &s5):a(s5.a) { }
42 public:
43 S5(int v):a(v) { }
46 S3 h;
47 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
49 namespace A {
50 double x;
51 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
53 namespace B {
54 using A::x;
57 int main(int argc, char **argv) {
58 const int d = 5;
59 const int da[5] = { 0 };
60 S4 e(4);
61 S5 g(5);
62 int i, k;
63 int &j = i;
64 #pragma omp parallel shared // expected-error {{expected '(' after 'shared'}}
65 #pragma omp parallel shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
66 #pragma omp parallel shared () // expected-error {{expected expression}}
67 #pragma omp parallel shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
68 #pragma omp parallel shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
69 #pragma omp parallel shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
70 #pragma omp parallel shared (argc)
71 #pragma omp parallel shared (S1) // expected-error {{'S1' does not refer to a value}}
72 #pragma omp parallel shared (a, b, c, d, f, k)
73 #pragma omp parallel shared (argv[1]) // expected-error {{expected variable name}}
74 #pragma omp parallel shared(ba)
75 #pragma omp parallel shared(ca)
76 #pragma omp parallel shared(da)
77 #pragma omp parallel shared(e, g)
78 #pragma omp parallel shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
79 #pragma omp parallel private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
80 foo();
81 #pragma omp parallel firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
82 foo();
83 #pragma omp parallel private(i)
84 #pragma omp parallel shared(i)
85 #pragma omp parallel shared(j)
86 foo();
87 #pragma omp parallel firstprivate(i)
88 #pragma omp parallel shared(i)
89 #pragma omp parallel shared(j)
90 foo();
92 return 0;