1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
4
5 extern int omp_default_mem_alloc;
foo()6 void foo() {
7 }
8
foobool(int argc)9 bool foobool(int argc) {
10 return argc;
11 }
12
13 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
14 extern S1 a;
15 class S2 {
16 mutable int a;
17 public:
S2()18 S2():a(0) { }
S2(const S2 & s2)19 S2(const S2 &s2):a(s2.a) { }
20 static float S2s;
21 static const float S2sc;
22 };
23 const float S2::S2sc = 0;
24 const S2 b;
25 const S2 ba[5];
26 class S3 {
27 int a;
28 public:
S3()29 S3():a(0) { }
S3(const S3 & s3)30 S3(const S3 &s3):a(s3.a) { }
31 };
32 const S3 c;
33 const S3 ca[5];
34 extern const int f;
35 class S4 {
36 int a;
37 S4();
38 S4(const S4 &s4); // expected-note {{implicitly declared private here}}
39 public:
S4(int v)40 S4(int v):a(v) { }
41 };
42 class S5 {
43 int a;
S5()44 S5():a(0) {}
S5(const S5 & s5)45 S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
46 public:
S5(int v)47 S5(int v):a(v) { }
48 };
49
50 S3 h;
51 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
52
53 namespace A {
54 double x;
55 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
56 }
57 namespace B {
58 using A::x;
59 }
60
main(int argc,char ** argv)61 int main(int argc, char **argv) {
62 const int d = 5; // expected-note {{variable 'd' declared const here}}
63 const int da[5] = { 0 };
64 S4 e(4);
65 S5 g(5);
66 int i, z;
67 int &j = i;
68 static int m;
69 #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
70 #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 #pragma omp parallel firstprivate () // expected-error {{expected expression}}
72 #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
73 #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
74 #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
75 #pragma omp parallel firstprivate (argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
76 #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
77 #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
78 #pragma omp parallel firstprivate (z, d)
79 d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
80 #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
81 #pragma omp parallel firstprivate(ba)
82 #pragma omp parallel firstprivate(ca)
83 #pragma omp parallel firstprivate(da)
84 #pragma omp parallel firstprivate(S2::S2s)
85 #pragma omp parallel firstprivate(S2::S2sc)
86 #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
87 #pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
88 #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
89 foo();
90 #pragma omp parallel shared(i)
91 #pragma omp parallel firstprivate(i)
92 #pragma omp parallel firstprivate(j)
93 #pragma omp parallel firstprivate(m)
94 foo();
95
96 return 0;
97 }
98