162 lines · cpp
1// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++14 \2// RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT3 4// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++14 \5// RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP6 7// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++14 -emit-pch -o %t %s8 9// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++14 -include-pch \10// RUN: %t -ast-print %s | FileCheck %s --check-prefix=PRINT11 12// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++14 -include-pch \13// RUN: %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP14// expected-no-diagnostics15 16#ifndef HEADER17#define HEADER18 19typedef enum omp_allocator_handle_t {20 omp_null_allocator = 0,21 omp_default_mem_alloc = 1,22 omp_large_cap_mem_alloc = 2,23 omp_const_mem_alloc = 3,24 omp_high_bw_mem_alloc = 4,25 omp_low_lat_mem_alloc = 5,26 omp_cgroup_mem_alloc = 6,27 omp_pteam_mem_alloc = 7,28 omp_thread_mem_alloc = 8,29} omp_allocator_handle_t;30 31omp_allocator_handle_t myAlloc() {32 return omp_large_cap_mem_alloc;33}34 35int main() {36 int a, b, c, d;37 #pragma omp scope private(a) allocate(omp_const_mem_alloc:a)38 a++;39 #pragma omp scope private(a,b) allocate(allocator(omp_const_mem_alloc):a,b)40 b++;41 #pragma omp scope private(c,a,b) allocate(allocator(myAlloc()):a,b,c)42 c++;43 #pragma omp scope private(c,a,b,d) allocate(myAlloc():a,b,c,d)44 a++;45 #pragma omp scope private(a,b) allocate(align(2), allocator(omp_const_mem_alloc):a,b)46 b++;47 #pragma omp scope private(c,a,b) allocate(allocator(myAlloc()), align(8) :a,b,c)48 c++;49// DUMP: FunctionDecl {{.*}}50// DUMP: DeclRefExpr {{.*}}'omp_allocator_handle_t' EnumConstant {{.*}}'omp_large_cap_mem_alloc' 'omp_allocator_handle_t'51// DUMP: FunctionDecl {{.*}}52// DUMP: OMPScopeDirective {{.*}}53// DUMP: OMPPrivateClause {{.*}}54// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'55// DUMP: OMPAllocateClause {{.*}}56// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'57// DUMP: OMPScopeDirective {{.*}}58// DUMP: OMPPrivateClause {{.*}}59// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'60// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'61// DUMP: OMPAllocateClause {{.*}}62// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'63// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'64// DUMP: OMPScopeDirective {{.*}}65// DUMP: OMPPrivateClause {{.*}}66// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'67// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'68// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'69// DUMP: OMPAllocateClause {{.*}}70// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'71// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'72// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'73// DUMP: OMPScopeDirective {{.*}}74// DUMP: OMPPrivateClause {{.*}}75// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'76// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'77// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'78// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'d' 'int'79// DUMP: OMPAllocateClause {{.*}}80// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'81// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'82// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'83// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'d' 'int'84// DUMP: OMPScopeDirective {{.*}}85// DUMP: OMPPrivateClause {{.*}}86// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'87// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'88// DUMP: OMPAllocateClause {{.*}}89// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'90// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'91// DUMP: OMPScopeDirective {{.*}}92// DUMP: OMPPrivateClause {{.*}}93// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'94// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'95// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'96// DUMP: OMPAllocateClause {{.*}}97// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'a' 'int'98// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'b' 'int'99// DUMP: DeclRefExpr {{.*}}'int' lvalue Var {{.*}}'c' 'int'100// PRINT: #pragma omp scope private(a) allocate(omp_const_mem_alloc: a)101// PRINT: #pragma omp scope private(a,b) allocate(allocator(omp_const_mem_alloc): a,b)102// PRINT: #pragma omp scope private(c,a,b) allocate(allocator(myAlloc()): a,b,c)103// PRINT: #pragma omp scope private(c,a,b,d) allocate(myAlloc(): a,b,c,d)104// PRINT: #pragma omp scope private(a,b) allocate(align(2), allocator(omp_const_mem_alloc): a,b)105// PRINT: #pragma omp scope private(c,a,b) allocate(allocator(myAlloc()), align(8): a,b,c)106 return a+b+c+d;107}108 109template<typename T, unsigned al>110void templated_func(T n) {111 int a, b;112 T mem = n;113 #pragma omp scope private(mem,a,b) allocate(allocator(n),align(al):mem,a,b)114 a += b;115 #pragma omp scope allocate(allocator(n),align(al):mem,a,b) private(mem,a,b)116 a += b;117}118 119void template_inst(int n) {120 templated_func<omp_allocator_handle_t, 4>(omp_const_mem_alloc);121 return;122}123// DUMP: FunctionTemplateDecl{{.*}}templated_func124// DUMP: FunctionDecl{{.*}}templated_func 'void (T)'125// DUMP: OMPScopeDirective126// DUMP: OMPPrivateClause127// DUMP: OMPAllocateClause128// DUMP: DeclRefExpr{{.*}}'T' lvalue Var{{.*}}'mem' 'T'129// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'a' 'int'130// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'b' 'int'131// DUMP: OMPScopeDirective132// DUMP: OMPAllocateClause133// DUMP: DeclRefExpr{{.*}}'T' lvalue Var{{.*}}'mem' 'T'134// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'a' 'int'135// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'b' 'int'136// DUMP: OMPPrivateClause137 138// DUMP: FunctionDecl{{.*}}used templated_func 'void (omp_allocator_handle_t)' implicit_instantiation139// DUMP: TemplateArgument type 'omp_allocator_handle_t'140// DUMP: EnumType{{.*}}'omp_allocator_handle_t'141// DUMP: Enum{{.*}}'omp_allocator_handle_t'142// DUMP: TemplateArgument integral '4U'143 144// DUMP: OMPScopeDirective145// DUMP: OMPPrivateClause146// DUMP: OMPAllocateClause147// DUMP: DeclRefExpr{{.*}}'omp_allocator_handle_t' lvalue Var{{.*}}'mem' 'omp_allocator_handle_t'148// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'a' 'int'149// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'b' 'int'150// DUMP: OMPScopeDirective151// DUMP: OMPAllocateClause152// DUMP: DeclRefExpr{{.*}}'omp_allocator_handle_t' lvalue Var{{.*}}'mem' 'omp_allocator_handle_t'153// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'a' 'int'154// DUMP: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'b' 'int'155// DUMP: OMPPrivateClause156// PRINT: #pragma omp scope private(mem,a,b) allocate(allocator(n), align(al): mem,a,b)157// PRINT: #pragma omp scope allocate(allocator(n), align(al): mem,a,b) private(mem,a,b)158// PRINT: #pragma omp scope private(mem,a,b) allocate(allocator(n), align(4U): mem,a,b)159// PRINT: #pragma omp scope allocate(allocator(n), align(4U): mem,a,b) private(mem,a,b)160 161#endif162