xref: /llvm-project/clang/test/OpenMP/align_clause_ast_print.cpp (revision 1a2f3309765fdc143fdc3809211fb85d2e2ca341)
1 // expected-no-diagnostics
2 
3 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
4 //RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \
5 //RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \
6 //RUN:   -ast-print %s | FileCheck %s --check-prefix=PRINT
7 
8 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
9 //RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \
10 //RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \
11 //RUN:   -ast-dump %s | FileCheck %s --check-prefix=DUMP
12 
13 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
14 //RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \
15 //RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \
16 //RUN:   -emit-pch -o %t %s
17 
18 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
19 //RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \
20 //RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \
21 //RUN:   -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
22 
23 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
24 //RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \
25 //RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \
26 //RUN:   -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
27 
28 #ifndef HEADER
29 #define HEADER
30 
31 typedef enum omp_allocator_handle_t {
32   omp_null_allocator = 0,
33   omp_default_mem_alloc = 1,
34   omp_large_cap_mem_alloc = 2,
35   omp_const_mem_alloc = 3,
36   omp_high_bw_mem_alloc = 4,
37   omp_low_lat_mem_alloc = 5,
38   omp_cgroup_mem_alloc = 6,
39   omp_pteam_mem_alloc = 7,
40   omp_thread_mem_alloc = 8,
41   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
42 } omp_allocator_handle_t;
43 
foo1()44 int foo1() {
45   char a;
46 #pragma omp allocate(a) align(4) allocator(omp_pteam_mem_alloc)
47   return a;
48 }
49 // DUMP: FunctionDecl {{.*}}
50 // DUMP: DeclStmt {{.*}}
51 // DUMP: VarDecl {{.*}}a 'char'
52 // DUMP: OMPAllocateDeclAttr {{.*}}OMPPTeamMemAlloc
53 // DUMP: DeclRefExpr {{.*}}'omp_allocator_handle_t' EnumConstant {{.*}} 'omp_pteam_mem_alloc' 'omp_allocator_handle_t'
54 // DUMP: ConstantExpr {{.*}}'int'
55 // DUMP: value: Int 4
56 // DUMP: IntegerLiteral {{.*}}'int' 4
57 // DUMP: DeclStmt {{.*}}
58 // DUMP: OMPAllocateDecl {{.*}}
59 // DUMP: DeclRefExpr {{.*}}'char' lvalue Var {{.*}} 'a' 'char'
60 // DUMP: OMPAlignClause {{.*}}
61 // DUMP: ConstantExpr {{.*}}'int'
62 // DUMP: value: Int 4
63 // DUMP: IntegerLiteral {{.*}}'int' 4
64 // DUMP: OMPAllocatorClause {{.*}}
65 // DUMP: DeclRefExpr {{.*}}'omp_allocator_handle_t' EnumConstant {{.*}}'omp_pteam_mem_alloc' 'omp_allocator_handle_t'
66 // PRINT: #pragma omp allocate(a) align(4) allocator(omp_pteam_mem_alloc)
67 
foo2()68 int foo2() {
69   char b;
70 #pragma omp allocate(b) allocator(omp_low_lat_mem_alloc) align(2)
71   return b;
72 }
73 // DUMP: FunctionDecl {{.*}}
74 // DUMP: DeclStmt {{.*}}
75 // DUMP: VarDecl {{.*}}b 'char'
76 // DUMP: OMPAllocateDeclAttr {{.*}}Implicit OMPLowLatMemAlloc
77 // DUMP: DeclRefExpr {{.*}}'omp_allocator_handle_t' EnumConstant {{.*}} 'omp_low_lat_mem_alloc' 'omp_allocator_handle_t'
78 // DUMP: ConstantExpr {{.*}}'int'
79 // DUMP: value: Int 2
80 // DUMP: IntegerLiteral {{.*}}'int' 2
81 // DUMP: DeclStmt {{.*}}
82 // DUMP: OMPAllocateDecl {{.*}}
83 // DUMP: DeclRefExpr {{.*}}'char' lvalue Var {{.*}} 'b' 'char'
84 // DUMP: OMPAllocatorClause {{.*}}
85 // DUMP: DeclRefExpr {{.*}}'omp_allocator_handle_t' EnumConstant {{.*}} 'omp_low_lat_mem_alloc' 'omp_allocator_handle_t'
86 // DUMP: OMPAlignClause {{.*}}
87 // DUMP:  ConstantExpr {{.*}}'int'
88 // DUMP: value: Int 2
89 // DUMP: IntegerLiteral {{.*}}'int' 2
90 // PRINT: #pragma omp allocate(b) allocator(omp_low_lat_mem_alloc) align(2)
91 
92 template <typename T, unsigned size>
run()93 T run() {
94   T foo;
95 #pragma omp allocate(foo) align(size)
96   return size;
97 }
98 
template_test()99 int template_test() {
100   double d;
101   d = run<double, 1>();
102   return 0;
103 }
104 
105 // DUMP: FunctionTemplateDecl {{.*}}
106 // DUMP: TemplateTypeParmDecl {{.*}}
107 // DUMP: NonTypeTemplateParmDecl {{.*}}'unsigned int' depth 0 index 1 size
108 // DUMP: FunctionDecl {{.*}}'T ()'
109 // DUMP: DeclStmt {{.*}}
110 // DUMP: OMPAllocateDecl {{.*}}
111 // DUMP: DeclRefExpr {{.*}}'T' lvalue Var {{.*}} 'foo' 'T'
112 // DUMP: OMPAlignClause {{.*}}
113 // DUMP: DeclRefExpr {{.*}}'unsigned int' NonTypeTemplateParm {{.*}} 'size' 'unsigned int'
114 // DUMP: FunctionDecl {{.*}}run 'double ()'
115 // DUMP: TemplateArgument type 'double'
116 // DUMP: BuiltinType {{.*}}'double'
117 // DUMP: TemplateArgument integral '1U'
118 // DUMP: OMPAllocateDeclAttr {{.*}}Implicit OMPNullMemAlloc
119 // DUMP: ConstantExpr {{.*}}'unsigned int'
120 // DUMP: value: Int 1
121 // DUMP: SubstNonTypeTemplateParmExpr {{.*}}'unsigned int'
122 // DUMP: NonTypeTemplateParmDecl {{.*}}'unsigned int' depth 0 index 1 size
123 // DUMP: IntegerLiteral {{.*}}'unsigned int' 1
124 // DUMP: OMPAllocateDecl {{.*}}
125 // DUMP: DeclRefExpr {{.*}}'double' lvalue Var {{.*}} 'foo' 'double'
126 // DUMP: OMPAlignClause {{.*}}
127 // DUMP: ConstantExpr {{.*}}'unsigned int'
128 // DUMP: value: Int 1
129 // DUMP: SubstNonTypeTemplateParmExpr {{.*}}'unsigned int'
130 // DUMP: NonTypeTemplateParmDecl {{.*}}'unsigned int' depth 0 index 1 size
131 // DUMP: IntegerLiteral {{.*}}'unsigned int' 1
132 // PRINT: #pragma omp allocate(foo) align(size)
133 // PRINT: #pragma omp allocate(foo) align(1U)
134 #endif // HEADER
135