1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -ast-print %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -ast-print %s -o - | FileCheck %s
5 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -o - | FileCheck %s
7 
8 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -ast-print %s -o - | FileCheck %s
9 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
11 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -ast-print %s -o - | FileCheck %s
12 // RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s
13 // RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -o - | FileCheck %s
14 // expected-no-diagnostics
15 
16 #ifndef HEADER
17 #define HEADER
18 
19 typedef void **omp_allocator_handle_t;
20 extern const omp_allocator_handle_t omp_null_allocator;
21 extern const omp_allocator_handle_t omp_default_mem_alloc;
22 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
23 extern const omp_allocator_handle_t omp_const_mem_alloc;
24 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
25 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
26 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
27 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
28 extern const omp_allocator_handle_t omp_thread_mem_alloc;
29 
30 struct St{
31  int a;
32 };
33 
34 struct St1{
35  int a;
36  static int b;
37 // CHECK: static int b;
38 #pragma omp allocate(b) allocator(omp_default_mem_alloc)
39 // CHECK-NEXT: #pragma omp allocate(St1::b) allocator(omp_default_mem_alloc){{$}}
40 } d;
41 
42 int a, b, c;
43 // CHECK: int a;
44 // CHECK: int b;
45 // CHECK: int c;
46 #pragma omp allocate(a) allocator(omp_large_cap_mem_alloc)
47 #pragma omp allocate(b) allocator(omp_const_mem_alloc)
48 // CHECK-NEXT: #pragma omp allocate(a) allocator(omp_large_cap_mem_alloc)
49 // CHECK-NEXT: #pragma omp allocate(b) allocator(omp_const_mem_alloc)
50 #pragma omp allocate(c, d) allocator(omp_high_bw_mem_alloc)
51 // CHECK-NEXT: #pragma omp allocate(c,d) allocator(omp_high_bw_mem_alloc)
52 
53 template <class T>
54 struct ST {
55   static T m;
56   #pragma omp allocate(m) allocator(omp_low_lat_mem_alloc)
57 };
58 
foo()59 template <class T> T foo() {
60   T v;
61   #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
62   v = ST<T>::m;
63   return v;
64 }
65 //CHECK: template <class T> T foo() {
66 //CHECK-NEXT: T v;
67 //CHECK-NEXT: #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
68 //CHECK: template<> int foo<int>() {
69 //CHECK-NEXT: int v;
70 //CHECK-NEXT: #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
71 
72 namespace ns{
73   int a;
74 }
75 // CHECK: namespace ns {
76 // CHECK-NEXT: int a;
77 // CHECK-NEXT: }
78 #pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc)
79 // CHECK-NEXT: #pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc)
80 
main()81 int main () {
82   static int a;
83 // CHECK: static int a;
84 #pragma omp allocate(a) allocator(omp_thread_mem_alloc)
85 // CHECK-NEXT: #pragma omp allocate(a) allocator(omp_thread_mem_alloc)
86   a=2;
87   int b = 3;
88 // CHECK: int b = 3;
89 #pragma omp allocate(b)
90 // CHECK-NEXT: #pragma omp allocate(b)
91   return (foo<int>());
92 }
93 
94 extern template int ST<int>::m;
95 #endif
96