1 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=40 -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=45 -fopenmp %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected -fopenmp-version=50 -fopenmp %s -Wuninitialized
5
6 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 %s -Wuninitialized
8
9 typedef void **omp_allocator_handle_t;
10 extern const omp_allocator_handle_t omp_null_allocator;
11 extern const omp_allocator_handle_t omp_default_mem_alloc;
12 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
13 extern const omp_allocator_handle_t omp_const_mem_alloc;
14 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
15 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
16 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
17 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
18 extern const omp_allocator_handle_t omp_thread_mem_alloc;
19
foo()20 void foo() {
21 }
22
foobool(int argc)23 bool foobool(int argc) {
24 return argc;
25 }
26
27 struct S1; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}}
28 extern S1 a;
29 class S2 {
30 mutable int a;
31 public:
S2()32 S2():a(0) { }
33 static float S2s; // expected-note {{predetermined as shared}}
34 };
35 const S2 b;
36 const S2 ba[5];
37 class S3 {
38 int a;
39 public:
S3()40 S3():a(0) { }
41 };
42 const S3 c; // expected-note {{'c' defined here}}
43 const S3 ca[5]; // expected-note {{'ca' defined here}}
44 extern const int f; // expected-note {{'f' declared here}}
45 class S4 {
46 int a;
47 S4(); // expected-note {{implicitly declared private here}}
48 public:
S4(int v)49 S4(int v):a(v) { }
50 };
51 class S5 {
52 int a;
S5()53 S5():a(0) {} // expected-note {{implicitly declared private here}}
54 public:
S5(int v)55 S5(int v):a(v) { }
56 };
57
58 S3 h;
59 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
60
61
main(int argc,char ** argv)62 int main(int argc, char **argv) {
63 const int d = 5; // expected-note {{'d' defined here}}
64 const int da[5] = { 0 }; // expected-note {{'da' defined here}}
65 S4 e(4);
66 S5 g(5);
67 int i, k;
68 int &j = i;
69
70 #pragma omp target teams distribute simd private // expected-error {{expected '(' after 'private'}}
71 for (int k = 0; k < argc; ++k) ++k;
72
73 #pragma omp target teams distribute simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
74 for (int k = 0; k < argc; ++k) ++k;
75
76 #pragma omp target teams distribute simd private () // expected-error {{expected expression}}
77 for (int k = 0; k < argc; ++k) ++k;
78
79 #pragma omp target teams distribute simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
80 for (int k = 0; k < argc; ++k) ++k;
81
82 #pragma omp target teams distribute simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (int k = 0; k < argc; ++k) ++k;
84
85 #pragma omp target teams distribute simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
86 for (int k = 0; k < argc; ++k) ++k;
87
88 #pragma omp target teams distribute simd private (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 '('}}
89 for (int k = 0; k < argc; ++k) ++k;
90
91 #pragma omp target teams distribute simd private (S1) // expected-error {{'S1' does not refer to a value}}
92 for (int k = 0; k < argc; ++k) ++k;
93
94 #pragma omp target teams distribute simd private (a, b, c, d, f) // expected-error {{private variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be private}} expected-error 2 {{const-qualified variable cannot be private}}
95 for (int k = 0; k < argc; ++k) ++k;
96
97 #pragma omp target teams distribute simd private (k, argv[1]) // expected-error {{expected variable name}}
98 for (int k = 0; k < argc; ++k) ++k;
99
100 #pragma omp target teams distribute simd private(ba) allocate(omp_thread_mem_alloc: ba) uses_allocators(omp_thread_mem_alloc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target teams distribute simd' directive}} le45-error {{unexpected OpenMP clause 'uses_allocators' in directive '#pragma omp target teams distribute simd'}}
101 for (int k = 0; k < argc; ++k) ++k;
102
103 #pragma omp target teams distribute simd private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}}
104 for (int k = 0; k < argc; ++k) ++k;
105
106 #pragma omp target teams distribute simd private(da) // expected-error {{const-qualified variable cannot be private}}
107 for (int k = 0; k < argc; ++k) ++k;
108
109 #pragma omp target teams distribute simd private(S2::S2s) // expected-error {{shared variable cannot be private}}
110 for (int k = 0; k < argc; ++k) ++k;
111
112 #pragma omp target teams distribute simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
113 for (int k = 0; k < argc; ++k) ++k;
114
115 #pragma omp target teams distribute simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
116 for (int k = 0; k < argc; ++k) ++k;
117
118 #pragma omp target teams distribute simd shared(i)
119 for (int k = 0; k < argc; ++k) ++k;
120
121 #pragma omp target teams distribute simd firstprivate(i), private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
122 for (int k = 0; k < argc; ++k) ++k;
123
124 #pragma omp target teams distribute simd private(j)
125 for (int k = 0; k < argc; ++k) ++k;
126
127 #pragma omp target teams distribute simd reduction(+:i)
128 for (int k = 0; k < argc; ++k) ++k;
129
130 #pragma omp distribute private(i)
131 for (int k = 0; k < 10; ++k) {
132 #pragma omp target teams distribute simd private(i)
133 for (int x = 0; x < 10; ++x) foo();
134 }
135
136 #pragma omp target teams distribute simd firstprivate(i)
137 for (int k = 0; k < 10; ++k) {
138 }
139
140 #pragma omp target teams distribute simd private(j) map(j) // le45-error {{private variable cannot be in a map clause in '#pragma omp target teams distribute simd' directive}} le45-note {{defined as private}}
141 for (int k = 0; k < argc; ++k) ++k;
142
143 return 0;
144 }
145