Clang Project

clang_source_code/test/OpenMP/teams_firstprivate_messages.cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target
2
3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target
4
5extern int omp_default_mem_alloc;
6void foo() {
7}
8
9bool foobool(int argc) {
10  return argc;
11}
12
13struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
14extern S1 a;
15class S2 {
16  mutable int a;
17
18public:
19  S2() : a(0) {}
20  S2(const S2 &s2) : a(s2.a) {}
21  static float S2s;
22  static const float S2sc;
23};
24const float S2::S2sc = 0;
25const S2 b;
26const S2 ba[5];
27class S3 {
28  int a;
29
30public:
31  S3() : a(0) {}
32  S3(const S3 &s3) : a(s3.a) {}
33};
34const S3 c;
35const S3 ca[5];
36extern const int f;
37class S4 {
38  int a;
39  S4();
40  S4(const S4 &s4); // expected-note {{implicitly declared private here}}
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) {} // expected-note {{implicitly declared private here}}
48public:
49  S5(int v) : a(v) {}
50};
51
52S3 h;
53#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
54
55namespace A {
56double x;
57#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
58}
59namespace B {
60using A::x;
61}
62
63int main(int argc, char **argv) {
64  const int d = 5;
65  const int da[5] = {0};
66  S4 e(4);
67  S5 g(5);
68  int i;
69  int &j = i;
70#pragma omp target
71#pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}}
72  foo();
73#pragma omp target
74#pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75  foo();
76#pragma omp target
77#pragma omp teams firstprivate() // expected-error {{expected expression}}
78  foo();
79#pragma omp target
80#pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
81  foo();
82#pragma omp target
83#pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
84  foo();
85#pragma omp target
86#pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
87  foo();
88#pragma omp target
89#pragma omp teams 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 '('}}
90  foo();
91#pragma omp target
92#pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
93  foo();
94#pragma omp target
95#pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
96  foo();
97#pragma omp target
98#pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}}
99  foo();
100#pragma omp target
101#pragma omp teams firstprivate(ba)
102  foo();
103#pragma omp target
104#pragma omp teams firstprivate(ca)
105  foo();
106#pragma omp target
107#pragma omp teams firstprivate(da)
108  foo();
109#pragma omp target
110#pragma omp teams firstprivate(S2::S2s)
111  foo();
112#pragma omp target
113#pragma omp teams firstprivate(S2::S2sc)
114  foo();
115#pragma omp target
116#pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
117  foo();
118#pragma omp target
119#pragma omp teams firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
120  foo();
121#pragma omp target
122#pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
123  foo();
124#pragma omp target
125#pragma omp teams shared(i)
126  foo();
127#pragma omp target
128#pragma omp teams firstprivate(i)
129  foo();
130#pragma omp target
131#pragma omp teams firstprivate(j)
132  foo();
133  static int m;
134#pragma omp target
135#pragma omp teams firstprivate(m) // OK
136  foo();
137
138  return 0;
139}
140