]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/parallel_sections_shared_messages.cpp
Vendor import of clang trunk r238337:
[FreeBSD/FreeBSD.git] / test / OpenMP / parallel_sections_shared_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3 void foo() {
4 }
5
6 bool foobool(int argc) {
7   return argc;
8 }
9
10 struct S1; // expected-note {{declared here}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14
15 public:
16   S2() : a(0) {}
17   S2(S2 &s2) : a(s2.a) {}
18 };
19 const S2 b;
20 const S2 ba[5];
21 class S3 {
22   int a;
23
24 public:
25   S3() : a(0) {}
26   S3(S3 &s3) : a(s3.a) {}
27 };
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
36 public:
37   S4(int v) : a(v) {}
38 };
39 class S5 {
40   int a;
41   S5() : a(0) {}
42   S5(const S5 &s5) : a(s5.a) {}
43
44 public:
45   S5(int v) : a(v) {}
46 };
47
48 S3 h;
49 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
50
51 namespace A {
52 double x;
53 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
54 }
55 namespace B {
56 using A::x;
57 }
58
59 int main(int argc, char **argv) {
60   const int d = 5;
61   const int da[5] = {0};
62   S4 e(4);
63   S5 g(5);
64   int i;
65   int &j = i;
66 #pragma omp parallel sections shared // expected-error {{expected '(' after 'shared'}}
67   { foo(); }
68 #pragma omp parallel sections shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
69   { foo(); }
70 #pragma omp parallel sections shared() // expected-error {{expected expression}}
71   { foo(); }
72 #pragma omp parallel sections shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
73   { foo(); }
74 #pragma omp parallel sections shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75   { foo(); }
76 #pragma omp parallel sections shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
77   { foo(); }
78 #pragma omp parallel sections shared(argc)
79   { foo(); }
80 #pragma omp parallel sections shared(S1) // expected-error {{'S1' does not refer to a value}}
81   { foo(); }
82 #pragma omp parallel sections shared(a, b, c, d, f)
83   { foo(); }
84 #pragma omp parallel sections shared(argv[1]) // expected-error {{expected variable name}}
85   { foo(); }
86 #pragma omp parallel sections shared(ba)
87   { foo(); }
88 #pragma omp parallel sections shared(ca)
89   { foo(); }
90 #pragma omp parallel sections shared(da)
91   { foo(); }
92 #pragma omp parallel sections shared(e, g)
93   { foo(); }
94 #pragma omp parallel sections shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
95   { foo(); }
96 #pragma omp parallel sections private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
97   { foo(); }
98 #pragma omp parallel sections firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
99   { foo(); }
100 #pragma omp parallel sections private(i)
101   {
102 #pragma omp parallel sections shared(i)
103     {
104 #pragma omp parallel sections shared(j)
105       { foo(); }
106     }
107   }
108 #pragma omp parallel sections firstprivate(i)
109   {
110 #pragma omp parallel sections shared(i)
111     {
112 #pragma omp parallel sections shared(j)
113       { foo(); }
114     }
115   }
116
117   return 0;
118 }