Debian Codegraph @

gcc/testsuite/g++.dg/gomp/allocate-1.C

raw
1 // { dg-do compile }
2 // { dg-additional-options "-std=c++11" }
3
4 typedef enum omp_allocator_handle_t
5 #if __cplusplus >= 201103L
6 : __UINTPTR_TYPE__
7 #endif
8 {
9 omp_null_allocator = 0,
10 omp_default_mem_alloc = 1,
11 omp_large_cap_mem_alloc = 2,
12 omp_const_mem_alloc = 3,
13 omp_high_bw_mem_alloc = 4,
14 omp_low_lat_mem_alloc = 5,
15 omp_cgroup_mem_alloc = 6,
16 omp_pteam_mem_alloc = 7,
17 omp_thread_mem_alloc = 8,
18 __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
19 } omp_allocator_handle_t;
20
21 namespace N1
22 {
23 using ::omp_allocator_handle_t;
24 void
25 foo (const omp_allocator_handle_t h)
26 {
27 int x = 0;
28 #pragma omp parallel allocate (h: x) private (x)
29 x = 1;
30 }
31 }
32
33 namespace N2
34 {
35 typedef enum omp_allocator_handle_t { my = 0 } omp_allocator_handle_t;
36 void
37 foo (omp_allocator_handle_t h)
38 {
39 int x = 0;
40 #pragma omp parallel allocate (h: x) private (x) // { dg-error "'allocate' clause allocator expression has type 'N2::omp_allocator_handle_t' rather than 'omp_allocator_handle_t'" }
41 x = 1;
42 }
43 }
44
45 struct S
46 {
47 void foo ()
48 {
49 #pragma omp parallel allocate (omp_default_mem_alloc:s) firstprivate (s)
50 s++;
51 }
52 int s;
53 };
54
55 template <typename T>
56 struct U
57 {
58 int foo ()
59 {
60 #pragma omp parallel allocate (omp_default_mem_alloc:s) firstprivate (s)
61 s++;
62 return 1;
63 }
64 T s;
65 };
66
67 template <typename T>
68 int foo (T t)
69 {
70 int x = 0;
71 #pragma omp parallel firstprivate (x) allocate (t: x)
72 x = 1;
73 return 0;
74 }
75
76 template <typename T>
77 int bar (T t)
78 {
79 int x = 0;
80 #pragma omp parallel firstprivate (x) allocate (t: x) // { dg-error "'allocate' clause allocator expression has type 'int' rather than 'omp_allocator_handle_t'" }
81 x = 1;
82 return 0;
83 }
84
85 omp_allocator_handle_t h;
86 int a = foo (h);
87 int b = bar (0);
88 int c = U<int> ().foo ();