[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / allocate_allocator_messages.cpp
blobc5927fccec4ed35a7d5a1b55708004cf320046ae
1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
5 struct St{
6 int a;
7 };
9 int sss;
10 #pragma omp allocate(sss) allocat // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
11 #pragma omp allocate(sss) allocate(sss) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp allocate'}}
12 #pragma omp allocate(sss) allocator // expected-error {{expected '(' after 'allocator'}}
13 #pragma omp allocate(sss) allocator(0, // expected-error {{expected ')'}} expected-error {{'omp_allocator_handle_t' type not found; include <omp.h>}} expected-note {{to match this '('}}
14 #pragma omp allocate(sss) allocator(0,sss // expected-error {{expected ')'}} expected-error {{'omp_allocator_handle_t' type not found; include <omp.h>}} expected-note {{to match this '('}}
15 #pragma omp allocate(sss) allocator(0,sss) // expected-error {{expected ')'}} expected-error {{'omp_allocator_handle_t' type not found; include <omp.h>}} expected-note {{to match this '('}}
16 #pragma omp allocate(sss) allocator(sss) // expected-error {{'omp_allocator_handle_t' type not found; include <omp.h>}}
18 typedef void **omp_allocator_handle_t;
19 extern const omp_allocator_handle_t omp_null_allocator;
20 extern const omp_allocator_handle_t omp_default_mem_alloc;
21 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
22 extern const omp_allocator_handle_t omp_const_mem_alloc;
23 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
24 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
25 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
26 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
27 extern const omp_allocator_handle_t omp_thread_mem_alloc;
29 struct St1{
30 int a;
31 static int b;
32 #pragma omp allocate(b) allocator(sss) // expected-error {{incompatible integer to pointer conversion initializing 'const omp_allocator_handle_t' (aka 'void **const') with an expression of type 'int'}} expected-note {{previous allocator is specified here}}
33 #pragma omp allocate(b)
34 #pragma omp allocate(b) allocator(omp_thread_mem_alloc) // expected-warning {{allocate directive specifies 'omp_thread_mem_alloc' allocator while previously used default}}
35 } d; // expected-note 2 {{'d' defined here}}
37 // expected-error@+1 {{expected one of the predefined allocators for the variables with the static storage: 'omp_default_mem_alloc', 'omp_large_cap_mem_alloc', 'omp_const_mem_alloc', 'omp_high_bw_mem_alloc', 'omp_low_lat_mem_alloc', 'omp_cgroup_mem_alloc', 'omp_pteam_mem_alloc' or 'omp_thread_mem_alloc'}}
38 #pragma omp allocate(d) allocator(nullptr)
39 extern void **allocator;
40 // expected-error@+1 {{expected one of the predefined allocators for the variables with the static storage: 'omp_default_mem_alloc', 'omp_large_cap_mem_alloc', 'omp_const_mem_alloc', 'omp_high_bw_mem_alloc', 'omp_low_lat_mem_alloc', 'omp_cgroup_mem_alloc', 'omp_pteam_mem_alloc' or 'omp_thread_mem_alloc'}}
41 #pragma omp allocate(d) allocator(allocator)
42 #pragma omp allocate(d) allocator(omp_thread_mem_alloc) // expected-note {{previous allocator is specified here}}
43 #pragma omp allocate(d) // expected-warning {{allocate directive specifies default allocator while previously used 'omp_thread_mem_alloc'}}
45 int c;
46 #pragma omp allocate(c) allocator(omp_thread_mem_alloc) // expected-note {{previous allocator is specified here}}
47 #pragma omp allocate(c) allocator(omp_high_bw_mem_alloc) // expected-warning {{allocate directive specifies 'omp_high_bw_mem_alloc' allocator while previously used 'omp_thread_mem_alloc'}}