Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/allocate-12.c

raw
1 /* TODO: enable for C++ once implemented. */
2 /* { dg-do compile { target c } } */
3
4 typedef enum omp_allocator_handle_t
5 #if __cplusplus >= 201103L
6 : __UINTPTR_TYPE__
7 #endif
8 {
9 omp_default_mem_alloc = 1,
10 omp_low_lat_mem_alloc = 5,
11 __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
12 } omp_allocator_handle_t;
13
14 int
15 f ()
16 {
17 omp_allocator_handle_t my_allocator;
18 int n = 5; /* { dg-note "to be allocated variable declared here" } */
19 my_allocator = omp_default_mem_alloc; /* { dg-note "modified here" } */
20 #pragma omp allocate(n) allocator(my_allocator) /* { dg-error "variable 'my_allocator' used in the 'allocator' clause must not be modified between declaration of 'n' and its 'allocate' directive" } */
21 n = 7;
22 return n;
23 }
24
25
26 int
27 g ()
28 {
29 int n = 5; /* { dg-note "to be allocated variable declared here" } */
30 omp_allocator_handle_t my_allocator = omp_low_lat_mem_alloc; /* { dg-note "declared here" } */
31 #pragma omp allocate(n) allocator(my_allocator) /* { dg-error "variable 'my_allocator' used in the 'allocator' clause must be declared before 'n'" } */
32 n = 7;
33 return n;
34 }
35
36 int
37 h ()
38 {
39 /* my_allocator uninitialized - but only diagnosed in the ME with -Wuninitialized;
40 see gomp/allocate-10.c. */
41 omp_allocator_handle_t my_allocator;
42 int n = 5;
43 #pragma omp allocate(n) allocator(my_allocator)
44 n = 7;
45 return n;
46 }