xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/parallel_private_messages.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
2f4a2713aSLionel Sambuc 
foo()3f4a2713aSLionel Sambuc void foo() {
4f4a2713aSLionel Sambuc }
5f4a2713aSLionel Sambuc 
foobool(int argc)6f4a2713aSLionel Sambuc bool foobool(int argc) {
7f4a2713aSLionel Sambuc   return argc;
8f4a2713aSLionel Sambuc }
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
11f4a2713aSLionel Sambuc extern S1 a;
12f4a2713aSLionel Sambuc class S2 {
13f4a2713aSLionel Sambuc   mutable int a;
14f4a2713aSLionel Sambuc public:
S2()15f4a2713aSLionel Sambuc   S2():a(0) { }
16*0a6a1f1dSLionel Sambuc   static float S2s; // expected-note {{static data member is predetermined as shared}}
17f4a2713aSLionel Sambuc };
18f4a2713aSLionel Sambuc const S2 b;
19f4a2713aSLionel Sambuc const S2 ba[5];
20f4a2713aSLionel Sambuc class S3 {
21f4a2713aSLionel Sambuc   int a;
22f4a2713aSLionel Sambuc public:
S3()23f4a2713aSLionel Sambuc   S3():a(0) { }
24f4a2713aSLionel Sambuc };
25*0a6a1f1dSLionel Sambuc const S3 c; // expected-note {{global variable is predetermined as shared}}
26*0a6a1f1dSLionel Sambuc const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
27*0a6a1f1dSLionel Sambuc extern const int f; // expected-note {{global variable is predetermined as shared}}
28*0a6a1f1dSLionel Sambuc class S4 {
29f4a2713aSLionel Sambuc   int a;
30*0a6a1f1dSLionel Sambuc   S4(); // expected-note {{implicitly declared private here}}
31f4a2713aSLionel Sambuc public:
S4(int v)32f4a2713aSLionel Sambuc   S4(int v):a(v) { }
33f4a2713aSLionel Sambuc };
34*0a6a1f1dSLionel Sambuc class S5 {
35f4a2713aSLionel Sambuc   int a;
S5()36*0a6a1f1dSLionel Sambuc   S5():a(0) {} // expected-note {{implicitly declared private here}}
37f4a2713aSLionel Sambuc public:
S5(int v)38f4a2713aSLionel Sambuc   S5(int v):a(v) { }
39f4a2713aSLionel Sambuc };
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc int threadvar;
42f4a2713aSLionel Sambuc #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
43f4a2713aSLionel Sambuc 
main(int argc,char ** argv)44f4a2713aSLionel Sambuc int main(int argc, char **argv) {
45*0a6a1f1dSLionel Sambuc   const int d = 5; // expected-note {{constant variable is predetermined as shared}}
46*0a6a1f1dSLionel Sambuc   const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
47*0a6a1f1dSLionel Sambuc   S4 e(4);
48*0a6a1f1dSLionel Sambuc   S5 g[] = {5, 6};
49f4a2713aSLionel Sambuc   int i;
50f4a2713aSLionel Sambuc   int &j = i; // expected-note {{'j' defined here}}
51f4a2713aSLionel Sambuc   #pragma omp parallel private // expected-error {{expected '(' after 'private'}}
52f4a2713aSLionel Sambuc   #pragma omp parallel private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
53f4a2713aSLionel Sambuc   #pragma omp parallel private () // expected-error {{expected expression}}
54f4a2713aSLionel Sambuc   #pragma omp parallel private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
55f4a2713aSLionel Sambuc   #pragma omp parallel private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56f4a2713aSLionel Sambuc   #pragma omp parallel private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
57f4a2713aSLionel Sambuc   #pragma omp parallel private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
58f4a2713aSLionel Sambuc   #pragma omp parallel private (S1) // expected-error {{'S1' does not refer to a value}}
59f4a2713aSLionel Sambuc   #pragma omp parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
60f4a2713aSLionel Sambuc   #pragma omp parallel private (argv[1]) // expected-error {{expected variable name}}
61f4a2713aSLionel Sambuc   #pragma omp parallel private(ba)
62f4a2713aSLionel Sambuc   #pragma omp parallel private(ca) // expected-error {{shared variable cannot be private}}
63f4a2713aSLionel Sambuc   #pragma omp parallel private(da) // expected-error {{shared variable cannot be private}}
64f4a2713aSLionel Sambuc   #pragma omp parallel private(S2::S2s) // expected-error {{shared variable cannot be private}}
65*0a6a1f1dSLionel Sambuc   #pragma omp parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
66f4a2713aSLionel Sambuc   #pragma omp parallel private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}}
67f4a2713aSLionel Sambuc   #pragma omp parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
68f4a2713aSLionel Sambuc   foo();
69f4a2713aSLionel Sambuc   #pragma omp parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
70f4a2713aSLionel Sambuc   foo();
71f4a2713aSLionel Sambuc   #pragma omp parallel private(i)
72f4a2713aSLionel Sambuc   #pragma omp parallel private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}}
73f4a2713aSLionel Sambuc   foo();
74f4a2713aSLionel Sambuc   #pragma omp parallel firstprivate(i)
75f4a2713aSLionel Sambuc   for (int k = 0; k < 10; ++k) {
76f4a2713aSLionel Sambuc     #pragma omp parallel private(i)
77f4a2713aSLionel Sambuc     foo();
78f4a2713aSLionel Sambuc   }
79f4a2713aSLionel Sambuc 
80f4a2713aSLionel Sambuc   return 0;
81f4a2713aSLionel Sambuc }
82