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