blob: 7de268fb3b7e78047a395da0fbeb7275c1248642 [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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
4
Alexey Bataevd5af8e42013-10-01 05:32:34 +00005void foo() {
6}
7
8bool foobool(int argc) {
9 return argc;
10}
11
12struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
13extern S1 a;
14class S2 {
15 mutable int a;
16public:
17 S2():a(0) { }
Alexey Bataev4a5bb772014-10-08 14:01:46 +000018 S2(const S2 &s2):a(s2.a) { }
Alexey Bataevd5af8e42013-10-01 05:32:34 +000019 static float S2s;
20 static const float S2sc;
21};
22const float S2::S2sc = 0;
23const S2 b;
24const S2 ba[5];
25class S3 {
26 int a;
27public:
28 S3():a(0) { }
Alexey Bataev4a5bb772014-10-08 14:01:46 +000029 S3(const S3 &s3):a(s3.a) { }
Alexey Bataevd5af8e42013-10-01 05:32:34 +000030};
31const S3 c;
32const S3 ca[5];
33extern const int f;
Alexey Bataev4a5bb772014-10-08 14:01:46 +000034class S4 {
Alexey Bataevd5af8e42013-10-01 05:32:34 +000035 int a;
36 S4();
Alexey Bataev4a5bb772014-10-08 14:01:46 +000037 S4(const S4 &s4); // expected-note {{implicitly declared private here}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000038public:
39 S4(int v):a(v) { }
40};
Alexey Bataev4a5bb772014-10-08 14:01:46 +000041class S5 {
Alexey Bataevd5af8e42013-10-01 05:32:34 +000042 int a;
43 S5():a(0) {}
Alexey Bataev4a5bb772014-10-08 14:01:46 +000044 S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000045public:
46 S5(int v):a(v) { }
47};
48
49S3 h;
50#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
51
Alexey Bataev6ddfe1a2015-04-16 13:49:42 +000052namespace A {
53double x;
54#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
55}
56namespace B {
57using A::x;
58}
59
Alexey Bataevd5af8e42013-10-01 05:32:34 +000060int main(int argc, char **argv) {
Alexey Bataev77aed732017-11-10 15:39:50 +000061 const int d = 5; // expected-note {{variable 'd' declared const here}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000062 const int da[5] = { 0 };
Alexey Bataev4a5bb772014-10-08 14:01:46 +000063 S4 e(4);
64 S5 g(5);
Alexey Bataevd5af8e42013-10-01 05:32:34 +000065 int i;
Alexey Bataevbd9fec12015-08-18 06:47:21 +000066 int &j = i;
Kelvin Li4eea8c62015-09-15 18:56:58 +000067 static int m;
Alexey Bataevd5af8e42013-10-01 05:32:34 +000068 #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
69 #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
70 #pragma omp parallel firstprivate () // expected-error {{expected expression}}
71 #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataevc5970622016-04-01 08:43:42 +000072 #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000073 #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
74 #pragma omp parallel firstprivate (argc)
75 #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
76 #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
Alexey Bataev77aed732017-11-10 15:39:50 +000077 #pragma omp parallel firstprivate (d)
78 d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
Alexey Bataevd5af8e42013-10-01 05:32:34 +000079 #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
80 #pragma omp parallel firstprivate(ba)
81 #pragma omp parallel firstprivate(ca)
82 #pragma omp parallel firstprivate(da)
83 #pragma omp parallel firstprivate(S2::S2s)
84 #pragma omp parallel firstprivate(S2::S2sc)
Alexey Bataev4a5bb772014-10-08 14:01:46 +000085 #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 +000086 #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 +000087 #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
88 foo();
89 #pragma omp parallel shared(i)
90 #pragma omp parallel firstprivate(i)
Alexey Bataevbd9fec12015-08-18 06:47:21 +000091 #pragma omp parallel firstprivate(j)
Kelvin Li4eea8c62015-09-15 18:56:58 +000092 #pragma omp parallel firstprivate(m)
Alexey Bataevd5af8e42013-10-01 05:32:34 +000093 foo();
94
95 return 0;
96}