aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp/allocate-16.c
blob: 08738030e6a728f21974f4373edc0e53c9c21616 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* TODO: enable for C++ once implemented. */
/* { dg-do compile { target c } } */

typedef enum omp_allocator_handle_t 
#if __cplusplus >= 201103L 
: __UINTPTR_TYPE__ 
#endif 
{ 
  omp_default_mem_alloc = 1, 
  omp_low_lat_mem_alloc = 5, 
  __omp_allocator_handle_t_max__ = __UINTPTR_MAX__ 
} omp_allocator_handle_t; 

omp_allocator_handle_t foo(int, int *);


void
f ()
{
  int v;  /* { dg-note "to be allocated variable declared here" } */
  int n = 5;
  int a = 1;  /* { dg-note "declared here" } */
  int b[n];
  b[a] = 5;
  #pragma omp allocate (v) allocator (foo (a, &b[a]))  /* { dg-error "variable 'a' used in the 'allocator' clause must be declared before 'v'" } */
}

void
g ()
{
  int n = 5;
  int a = 1;
  int b[n];
  b[a] = 5;
  int v;  /* { dg-note "to be allocated variable declared here" } */
  a = 2;  /* { dg-note "modified here" } */
  #pragma omp allocate (v) allocator (foo (a, &b[a]))  /* { dg-error "variable 'a' used in the 'allocator' clause must not be modified between declaration of 'v' and its 'allocate' directive" } */
}