blob: 8acc6b643f09af7666dc3b4ed941b9edf70909ca [file] [log] [blame]
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001// RUN: %clang_cc1 -verify -fopenmp %s
2
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd %s
4
Carlo Bertolli6200a3d2015-12-14 14:51:25 +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;
16
17public:
18 S2() : a(0) {}
19 S2(const S2 &s2) : a(s2.a) {}
20 static float S2s;
21 static const float S2sc;
22};
23const float S2::S2sc = 0;
24const S2 b;
25const S2 ba[5];
26class S3 {
27 int a;
28 S3 &operator=(const S3 &s3);
29
30public:
31 S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
32 S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
33};
34const S3 c;
35const S3 ca[5];
36extern const int f;
37class S4 {
38 int a;
39 S4();
40 S4(const S4 &s4);
41public:
42 S4(int v):a(v) { }
43};
44class S5 {
45 int a;
46 S5():a(0) {}
47 S5(const S5 &s5):a(s5.a) { }
48public:
49 S5(int v):a(v) { }
50};
51class S6 {
52 int a;
53public:
54 S6() : a(0) { }
55};
56
57S3 h;
58#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
59
60int main(int argc, char **argv) {
61 const int d = 5;
62 const int da[5] = { 0 };
63 S4 e(4);
64 S5 g(5);
65 S6 p;
66 int i;
67 int &j = i;
68 #pragma omp distribute firstprivate // expected-error {{expected '(' after 'firstprivate'}}
69 for (i = 0; i < argc; ++i) foo();
70 #pragma omp distribute firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 for (i = 0; i < argc; ++i) foo();
72 #pragma omp distribute firstprivate () // expected-error {{expected expression}}
73 for (i = 0; i < argc; ++i) foo();
74 #pragma omp target
75 #pragma omp teams
76 #pragma omp distribute firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
77 for (i = 0; i < argc; ++i) foo();
78 #pragma omp target
79 #pragma omp teams
Alexey Bataevc5970622016-04-01 08:43:42 +000080 #pragma omp distribute firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +000081 for (i = 0; i < argc; ++i) foo();
82 #pragma omp target
83 #pragma omp teams
84 #pragma omp distribute firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
85 for (i = 0; i < argc; ++i) foo();
86 #pragma omp target
87 #pragma omp teams
88 #pragma omp distribute firstprivate (argc)
89 for (i = 0; i < argc; ++i) foo();
90 #pragma omp target
91 #pragma omp teams
92 #pragma omp distribute firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
93 for (i = 0; i < argc; ++i) foo();
94 #pragma omp target
95 #pragma omp teams
Alexey Bataevf07946e2018-10-29 20:17:42 +000096 #pragma omp distribute firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-warning {{Non-trivial type 'const S2' is mapped, only trivial types are guaranteed to be mapped correctly}} expected-warning {{Non-trivial type 'const S3' is mapped, only trivial types are guaranteed to be mapped correctly}} expected-error {{incomplete type 'S1' where a complete type is required}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +000097 for (i = 0; i < argc; ++i) foo();
98 #pragma omp target
99 #pragma omp teams
100 #pragma omp distribute firstprivate (argv[1]) // expected-error {{expected variable name}}
101 for (i = 0; i < argc; ++i) foo();
102 #pragma omp target
103 #pragma omp teams
Alexey Bataevf07946e2018-10-29 20:17:42 +0000104 #pragma omp distribute firstprivate(ba) // expected-warning {{Non-trivial type 'const S2 [5]' is mapped, only trivial types are guaranteed to be mapped correctly}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000105 for (i = 0; i < argc; ++i) foo();
106 #pragma omp target
107 #pragma omp teams
Alexey Bataevf07946e2018-10-29 20:17:42 +0000108 #pragma omp distribute firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} expected-warning {{Non-trivial type 'const S3 [5]' is mapped, only trivial types are guaranteed to be mapped correctly}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000109 for (i = 0; i < argc; ++i) foo();
110 #pragma omp target
111 #pragma omp teams
112 #pragma omp distribute firstprivate(da)
113 for (i = 0; i < argc; ++i) foo();
114 #pragma omp target
115 #pragma omp teams
116 #pragma omp distribute firstprivate(S2::S2s)
117 for (i = 0; i < argc; ++i) foo();
118 #pragma omp target
119 #pragma omp teams
120 #pragma omp distribute firstprivate(S2::S2sc)
121 for (i = 0; i < argc; ++i) foo();
122 #pragma omp target
123 #pragma omp teams
124 #pragma omp distribute firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
125 for (i = 0; i < argc; ++i) foo();
126 #pragma omp target
127 #pragma omp teams
128 #pragma omp distribute private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
129 for (i = 0; i < argc; ++i) foo();
130 #pragma omp target
131 #pragma omp teams shared(i)
132 #pragma omp distribute firstprivate(i)
133 for (j = 0; j < argc; ++j) foo();
134 #pragma omp target
135 #pragma omp teams shared(i)
136 #pragma omp distribute firstprivate(i) // expected-note {{defined as firstprivate}}
137 for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp distribute' directive may not be firstprivate, predetermined as private}}
138 #pragma omp target
139 #pragma omp teams private(argc) // expected-note {{defined as private}}
Alexey Bataeveffbdf12017-07-21 17:24:30 +0000140 #pragma omp distribute firstprivate(argc) // expected-error {{firstprivate variable must be shared}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000141 for (i = 0; i < argc; ++i) foo();
142 #pragma omp target
143 #pragma omp teams reduction(+:argc) // expected-note {{defined as reduction}}
Alexey Bataeveffbdf12017-07-21 17:24:30 +0000144 #pragma omp distribute firstprivate(argc) // expected-error {{firstprivate variable must be shared}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000145 for (i = 0; i < argc; ++i) foo();
146 #pragma omp target
147 #pragma omp teams
148 #pragma omp distribute firstprivate(j)
149 for (i = 0; i < argc; ++i) foo();
150 #pragma omp target
151 #pragma omp teams
Alexey Bataeveffbdf12017-07-21 17:24:30 +0000152 #pragma omp distribute lastprivate(argc), firstprivate(argc) // expected-error {{lastprivate variable cannot be firstprivate}} expected-note{{defined as lastprivate}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000153 for (i = 0; i < argc; ++i) foo();
154 #pragma omp target
155 #pragma omp teams
Alexey Bataeveffbdf12017-07-21 17:24:30 +0000156#pragma omp distribute firstprivate(argc), lastprivate(argc) // expected-error {{firstprivate variable cannot be lastprivate}} expected-note{{defined as firstprivate}}
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000157 for (i = 0; i < argc; ++i) foo();
158 return 0;
159}