blob: fc0eb4c7d3586b836ce18dc80facf9b520c15f25 [file] [log] [blame]
Alexey Bataevdb390212015-05-20 04:24:19 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
Alexey Bataevd5af8e42013-10-01 05:32:34 +00002
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
11extern S1 a;
12class S2 {
13 mutable int a;
14public:
15 S2():a(0) { }
Alexey Bataev4a5bb772014-10-08 14:01:46 +000016 S2(const S2 &s2):a(s2.a) { }
Alexey Bataevd5af8e42013-10-01 05:32:34 +000017 static float S2s;
18 static const float S2sc;
19};
20const float S2::S2sc = 0;
21const S2 b;
22const S2 ba[5];
23class S3 {
24 int a;
25public:
26 S3():a(0) { }
Alexey Bataev4a5bb772014-10-08 14:01:46 +000027 S3(const S3 &s3):a(s3.a) { }
Alexey Bataevd5af8e42013-10-01 05:32:34 +000028};
29const S3 c;
30const S3 ca[5];
31extern const int f;
Alexey Bataev4a5bb772014-10-08 14:01:46 +000032class S4 {
Alexey Bataevd5af8e42013-10-01 05:32:34 +000033 int a;
34 S4();
Alexey Bataev4a5bb772014-10-08 14:01:46 +000035 S4(const S4 &s4); // expected-note {{implicitly declared private here}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000036public:
37 S4(int v):a(v) { }
38};
Alexey Bataev4a5bb772014-10-08 14:01:46 +000039class S5 {
Alexey Bataevd5af8e42013-10-01 05:32:34 +000040 int a;
41 S5():a(0) {}
Alexey Bataev4a5bb772014-10-08 14:01:46 +000042 S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000043public:
44 S5(int v):a(v) { }
45};
46
47S3 h;
48#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
49
Alexey Bataev6ddfe1a2015-04-16 13:49:42 +000050namespace A {
51double x;
52#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
53}
54namespace B {
55using A::x;
56}
57
Alexey Bataevd5af8e42013-10-01 05:32:34 +000058int main(int argc, char **argv) {
59 const int d = 5;
60 const int da[5] = { 0 };
Alexey Bataev4a5bb772014-10-08 14:01:46 +000061 S4 e(4);
62 S5 g(5);
Alexey Bataevd5af8e42013-10-01 05:32:34 +000063 int i;
Alexey Bataevbd9fec12015-08-18 06:47:21 +000064 int &j = i;
Kelvin Li4eea8c62015-09-15 18:56:58 +000065 static int m;
Alexey Bataevd5af8e42013-10-01 05:32:34 +000066 #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
67 #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68 #pragma omp parallel firstprivate () // expected-error {{expected expression}}
69 #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
70 #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
72 #pragma omp parallel firstprivate (argc)
73 #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
74 #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
75 #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
76 #pragma omp parallel firstprivate(ba)
77 #pragma omp parallel firstprivate(ca)
78 #pragma omp parallel firstprivate(da)
79 #pragma omp parallel firstprivate(S2::S2s)
80 #pragma omp parallel firstprivate(S2::S2sc)
Alexey Bataev4a5bb772014-10-08 14:01:46 +000081 #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
Alexey Bataev6ddfe1a2015-04-16 13:49:42 +000082 #pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000083 #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
84 foo();
85 #pragma omp parallel shared(i)
86 #pragma omp parallel firstprivate(i)
Alexey Bataevbd9fec12015-08-18 06:47:21 +000087 #pragma omp parallel firstprivate(j)
Kelvin Li4eea8c62015-09-15 18:56:58 +000088 #pragma omp parallel firstprivate(m)
Alexey Bataevd5af8e42013-10-01 05:32:34 +000089 foo();
90
91 return 0;
92}