]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_teams_distribute_firstprivate_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 void foo() {
4 }
5
6 bool foobool(int argc) {
7   return argc;
8 }
9
10 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14   
15 public:
16   S2() : a(0) {}
17   S2(const S2 &s2) : a(s2.a) {}
18   static float S2s;
19   static const float S2sc;
20 };
21 const float S2::S2sc = 0;
22 const S2 b;
23 const S2 ba[5];
24 class S3 {
25   int a;
26   S3 &operator=(const S3 &s3);
27   
28 public:
29   S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
30   S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
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);
39 public:
40   S4(int v):a(v) { }
41 };
42 class S5 {
43   int a;
44   S5():a(0) {}
45   S5(const S5 &s5):a(s5.a) { }
46 public:
47   S5(int v):a(v) { }
48 };
49 class S6 {
50   int a;
51 public:
52   S6() : a(0) { }
53 };
54
55 S3 h;
56 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
57
58 int main(int argc, char **argv) {
59   const int d = 5;
60   const int da[5] = { 0 };
61   S4 e(4);
62   S5 g(5);
63   S6 p;
64   int i;
65   int &j = i;
66
67 #pragma omp target teams distribute firstprivate // expected-error {{expected '(' after 'firstprivate'}}
68   for (i = 0; i < argc; ++i) foo();
69
70 #pragma omp target teams distribute firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71   for (i = 0; i < argc; ++i) foo();
72
73 #pragma omp target teams distribute firstprivate () // expected-error {{expected expression}}
74   for (i = 0; i < argc; ++i) foo();
75
76 #pragma omp target teams distribute firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
77   for (i = 0; i < argc; ++i) foo();
78
79 #pragma omp target teams distribute firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80   for (i = 0; i < argc; ++i) foo();
81
82 #pragma omp target teams distribute firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
83   for (i = 0; i < argc; ++i) foo();
84
85 #pragma omp target teams distribute firstprivate (argc)
86   for (i = 0; i < argc; ++i) foo();
87
88 #pragma omp target teams distribute firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
89   for (i = 0; i < argc; ++i) foo();
90
91 #pragma omp target teams distribute firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
92   for (i = 0; i < argc; ++i) foo();
93
94 #pragma omp target teams distribute firstprivate (argv[1]) // expected-error {{expected variable name}}
95   for (i = 0; i < argc; ++i) foo();
96
97 #pragma omp target teams distribute firstprivate(ba)
98   for (i = 0; i < argc; ++i) foo();
99
100 #pragma omp target
101 #pragma omp teams distribute firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
102   for (i = 0; i < argc; ++i) foo();
103
104 #pragma omp target teams distribute firstprivate(da)
105   for (i = 0; i < argc; ++i) foo();
106
107 #pragma omp target teams distribute firstprivate(S2::S2s)
108   for (i = 0; i < argc; ++i) foo();
109
110 #pragma omp target teams distribute firstprivate(S2::S2sc)
111   for (i = 0; i < argc; ++i) foo();
112
113 #pragma omp target teams distribute firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
114   for (i = 0; i < argc; ++i) foo();
115
116 #pragma omp target teams distribute private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
117   for (i = 0; i < argc; ++i) foo();
118
119 #pragma omp target teams distribute firstprivate(i)
120   for (j = 0; j < argc; ++j) foo();
121
122 #pragma omp target teams distribute firstprivate(i) // expected-note {{defined as firstprivate}}
123   for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}}
124
125 #pragma omp target teams distribute firstprivate(j)
126   for (i = 0; i < argc; ++i) foo();
127
128 #pragma omp target teams distribute lastprivate(argc), firstprivate(argc) // OK
129   for (i = 0; i < argc; ++i) foo();
130
131   return 0;
132 }