Debian Codegraph @

gcc/testsuite/g++.dg/gomp/allocate-4.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 (allocator (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 (allocator (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 (allocator(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 (allocator(omp_default_mem_alloc):s) firstprivate (s)
61 s++;
62 return 1;
63 }
64 T s;
65 };
66
67 template <typename T, int N>
68 int foo (T t)
69 {
70 int x = 0;
71 #pragma omp parallel firstprivate (x) allocate (allocator(t), align (N): 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 (allocator(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 template <typename T, int N>
86 int baz (T t)
87 {
88 int x = 0;
89 #pragma omp parallel firstprivate (x) allocate (allocator(t), align (N): x) // { dg-error "'allocate' clause 'align' modifier argument needs to be positive constant power of two integer expression" }
90 x = 1;
91 return 0;
92 }
93
94 template <typename T>
95 int qux ()
96 {
97 int x = 0;
98 #pragma omp parallel firstprivate (x) allocate (align ((T) 16): x) // { dg-error "'allocate' clause 'align' modifier argument needs to be positive constant power of two integer expression" }
99 x = 1;
100 return 0;
101 }
102
103 omp_allocator_handle_t h;
104 int a = foo<omp_allocator_handle_t, 16> (h);
105 int b = bar (0);
106 int c = U<int> ().foo ();
107 int d = baz<omp_allocator_handle_t, 13> (h);
108 int e = qux<long double> ();