• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s
2 
foo()3 void foo() {
4 }
5 
foobool(int argc)6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14 public:
S2()15   S2():a(0) { }
16   static float S2s; // expected-note {{predetermined as shared}}
17 };
18 const S2 b;
19 const S2 ba[5];
20 class S3 {
21   int a;
22 public:
S3()23   S3():a(0) { }
24 };
25 const S3 c; // expected-note {{predetermined as shared}}
26 const S3 ca[5]; // expected-note {{predetermined as shared}}
27 extern const int f;  // expected-note {{predetermined as shared}}
28 class S4 {
29   int a;
30   S4(); // expected-note {{implicitly declared private here}}
31 public:
S4(int v)32   S4(int v):a(v) { }
33 };
34 class S5 {
35   int a;
S5()36   S5():a(0) {} // expected-note {{implicitly declared private here}}
37 public:
S5(int v)38   S5(int v):a(v) { }
39 };
40 
41 S3 h;
42 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
43 
44 
main(int argc,char ** argv)45 int main(int argc, char **argv) {
46   const int d = 5;  // expected-note {{predetermined as shared}}
47   const int da[5] = { 0 }; // expected-note {{predetermined as shared}}
48   S4 e(4);
49   S5 g(5);
50   int i;
51   int &j = i;
52  #pragma omp distribute private // expected-error {{expected '(' after 'private'}}
53   for (int k = 0; k < argc; ++k) ++k;
54   #pragma omp distribute private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
55   for (int k = 0; k < argc; ++k) ++k;
56   #pragma omp distribute private () // expected-error {{expected expression}}
57   for (int k = 0; k < argc; ++k) ++k;
58   #pragma omp distribute private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (int k = 0; k < argc; ++k) ++k;
60   #pragma omp distribute private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
61   for (int k = 0; k < argc; ++k) ++k;
62   #pragma omp distribute private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
63   for (int k = 0; k < argc; ++k) ++k;
64   #pragma omp distribute private (argc)
65   for (int k = 0; k < argc; ++k) ++k;
66   #pragma omp distribute private (S1) // expected-error {{'S1' does not refer to a value}}
67   for (int k = 0; k < argc; ++k) ++k;
68   #pragma omp distribute private (a, b, c, d, f) // expected-error {{private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
69   for (int k = 0; k < argc; ++k) ++k;
70   #pragma omp distribute private (argv[1]) // expected-error {{expected variable name}}
71   for (int k = 0; k < argc; ++k) ++k;
72   #pragma omp distribute private(ba)
73   for (int k = 0; k < argc; ++k) ++k;
74   #pragma omp distribute private(ca) // expected-error {{shared variable cannot be private}}
75   for (int k = 0; k < argc; ++k) ++k;
76   #pragma omp distribute private(da) // expected-error {{shared variable cannot be private}}
77   for (int k = 0; k < argc; ++k) ++k;
78   #pragma omp distribute private(S2::S2s) // expected-error {{shared variable cannot be private}}
79   for (int k = 0; k < argc; ++k) ++k;
80   #pragma omp distribute private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
81   for (int k = 0; k < argc; ++k) ++k;
82   #pragma omp distribute private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
83   for (int k = 0; k < argc; ++k) ++k;
84   #pragma omp distribute shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp distribute'}}
85   for (int k = 0; k < argc; ++k) ++k;
86   #pragma omp target
87   #pragma omp teams
88   {
89     int i; // expected-note {{predetermined as private}}
90     #pragma omp distribute firstprivate(i), private(i) // expected-error {{private variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'}}
91     for (int k = 0; k < argc; ++k) ++k;
92   }
93   #pragma omp target
94   #pragma omp teams private(i)
95   #pragma omp distribute private(j)
96   for (int k = 0; k < argc; ++k) ++k;
97   #pragma omp parallel private(i)
98   #pragma omp target
99   #pragma omp teams firstprivate(i)
100   #pragma omp parallel private(i)
101   {}
102   #pragma omp target
103   #pragma omp teams reduction(+:i)
104   #pragma omp distribute private(i)
105   for (int k = 0; k < argc; ++k) ++k;
106   #pragma omp distribute private(i)
107   for (int k = 0; k < 10; ++k) {
108     #pragma omp target
109     #pragma omp teams private(i)
110     #pragma omp distribute private(i)
111     for (int x = 0; x < 10; ++x) foo();
112   }
113   #pragma omp target
114   #pragma omp teams
115   #pragma omp distribute firstprivate(i)
116   for (int k = 0; k < 10; ++k) {
117   }
118   #pragma omp target
119   #pragma omp teams firstprivate(i)
120   #pragma omp distribute private(i)
121   for (int x = 0; x < 10; ++x) foo();
122   #pragma omp target
123   #pragma omp teams reduction(+:i)
124   #pragma omp distribute
125   for (int k = 0; k < 10; ++k) {
126   }
127   #pragma omp target
128   #pragma omp teams reduction(+:i)
129   #pragma omp distribute private(i)
130   for (int x = 0; x < 10; ++x) foo();
131 
132   return 0;
133 }
134