• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -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}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14 public:
S2()15   S2():a(0) { }
S2(S2 & s2)16   S2(S2 &s2):a(s2.a) { }
17 };
18 const S2 b;
19 const S2 ba[5];
20 class S3 {
21   int a;
22 public:
S3()23   S3():a(0) { }
S3(S3 & s3)24   S3(S3 &s3):a(s3.a) { }
25 };
26 const S3 c;
27 const S3 ca[5];
28 extern const int f;
29 class S4 {
30   int a;
31   S4();
32   S4(const S4 &s4);
33 public:
S4(int v)34   S4(int v):a(v) { }
35 };
36 class S5 {
37   int a;
S5()38   S5():a(0) {}
S5(const S5 & s5)39   S5(const S5 &s5):a(s5.a) { }
40 public:
S5(int v)41   S5(int v):a(v) { }
42 };
43 
44 S3 h;
45 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
46 
main(int argc,char ** argv)47 int main(int argc, char **argv) {
48   const int d = 5;
49   const int da[5] = { 0 };
50   S4 e(4);
51   S5 g(5);
52   int i;
53   int &j = i;
54   #pragma omp parallel shared // expected-error {{expected '(' after 'shared'}}
55   #pragma omp parallel shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56   #pragma omp parallel shared () // expected-error {{expected expression}}
57   #pragma omp parallel shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
58   #pragma omp parallel shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
59   #pragma omp parallel shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
60   #pragma omp parallel shared (argc)
61   #pragma omp parallel shared (S1) // expected-error {{'S1' does not refer to a value}}
62   #pragma omp parallel shared (a, b, c, d, f)
63   #pragma omp parallel shared (argv[1]) // expected-error {{expected variable name}}
64   #pragma omp parallel shared(ba)
65   #pragma omp parallel shared(ca)
66   #pragma omp parallel shared(da)
67   #pragma omp parallel shared(e, g)
68   #pragma omp parallel shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}}
69   #pragma omp parallel private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
70   foo();
71   #pragma omp parallel firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
72   foo();
73   #pragma omp parallel private(i)
74   #pragma omp parallel shared(i)
75   #pragma omp parallel shared(j)
76   foo();
77   #pragma omp parallel firstprivate(i)
78   #pragma omp parallel shared(i)
79   #pragma omp parallel shared(j)
80   foo();
81 
82   return 0;
83 }
84