1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
|
// RUN: %clang_cc1 -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s
// RUN: %clang_cc1 -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -I %S/Inputs -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
// RUN: %clang_cc1 -verify -fopenmp-simd -I %S/Inputs -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s
// expected-no-diagnostics
#ifndef HEADER
#define HEADER
#if _OPENMP == 201811
void bar();
#pragma omp declare target to(bar) device_type(any)
// OMP50: #pragma omp declare target{{$}}
// OMP50: void bar();
// OMP50: #pragma omp end declare target{{$}}
void baz();
#pragma omp declare target to(baz) device_type(nohost)
// OMP50: #pragma omp declare target device_type(nohost){{$}}
// OMP50: void baz();
// OMP50: #pragma omp end declare target{{$}}
void bazz();
#pragma omp declare target to(bazz) device_type(host)
// OMP50: #pragma omp declare target device_type(host){{$}}
// OMP50: void bazz();
// OMP50: #pragma omp end declare target{{$}}
#endif // _OPENMP
#if _OPENMP == 202011
extern "C" {
void boo_c() {}
#pragma omp declare target to(boo_c) indirect
// OMP51: #pragma omp declare target indirect
// OMP51: void boo_c() {
// OMP51: }
// OMP51: #pragma omp end declare target
#pragma omp declare target indirect
void yoo(){}
#pragma omp end declare target
// OMP51: #pragma omp declare target indirect
// OMP51: void yoo() {
// OMP51: }
// OMP51: #pragma omp end declare target
}
extern "C++" {
void boo_cpp() {}
#pragma omp declare target to(boo_cpp) indirect
// OMP51: #pragma omp declare target indirect
// OMP51: void boo_cpp() {
// OMP51: }
// OMP51: #pragma omp end declare target
constexpr bool f() {return false;}
#pragma omp begin declare target indirect(f())
void zoo() {}
void xoo();
#pragma omp end declare target
#pragma omp declare target to(zoo) indirect(false)
// OMP51: #pragma omp declare target indirect(f())
// OMP51: #pragma omp declare target indirect(false)
// OMP51: void zoo() {
// OMP51: }
// OMP51: #pragma omp end declare target
// OMP51: #pragma omp declare target indirect(f())
// OMP51: void xoo();
// OMP51: #pragma omp end declare target
}
#endif // _OPENMP
int out_decl_target = 0;
#pragma omp declare target (out_decl_target)
// CHECK: #pragma omp declare target{{$}}
// CHECK: int out_decl_target = 0;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target{{$}}
// CHECK: void lambda()
// CHECK: #pragma omp end declare target{{$}}
#pragma omp declare target
void lambda () {
#ifdef __cpp_lambdas
(void)[&] { ++out_decl_target; };
#else
#pragma clang __debug captured
(void)out_decl_target;
#endif
};
#pragma omp end declare target
#pragma omp declare target
// CHECK: #pragma omp declare target{{$}}
void foo() {}
// CHECK-NEXT: void foo()
#pragma omp end declare target
// CHECK: #pragma omp end declare target{{$}}
extern "C" {
#pragma omp declare target
// CHECK: #pragma omp declare target
void foo_c() {}
// CHECK-NEXT: void foo_c()
#pragma omp end declare target
// CHECK: #pragma omp end declare target
}
extern "C++" {
#pragma omp declare target
// CHECK: #pragma omp declare target
void foo_cpp() {}
// CHECK-NEXT: void foo_cpp()
#pragma omp end declare target
// CHECK: #pragma omp end declare target
}
#pragma omp declare target
template <class T>
struct C {
// CHECK: template <class T> struct C {
// CHECK: #pragma omp declare target
// CHECK-NEXT: static T ts;
// CHECK-NEXT: #pragma omp end declare target
// CHECK: template<> struct C<int>
T t;
// CHECK-NEXT: int t;
static T ts;
// CHECK-NEXT: #pragma omp declare target
// CHECK-NEXT: static int ts;
// CHECK: #pragma omp end declare target
C(T t) : t(t) {
}
// CHECK: #pragma omp declare target
// CHECK-NEXT: C(int t) : t(t) {
// CHECK-NEXT: }
// CHECK: #pragma omp end declare target
T foo() {
return t;
}
// CHECK: #pragma omp declare target
// CHECK-NEXT: int foo() {
// CHECK-NEXT: return this->t;
// CHECK-NEXT: }
// CHECK: #pragma omp end declare target
};
template<class T>
T C<T>::ts = 1;
// CHECK: #pragma omp declare target
// CHECK: T ts = 1;
// CHECK: #pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: int test1()
int test1() {
C<int> c(1);
return c.foo() + c.ts;
}
#pragma omp end declare target
// CHECK: #pragma omp end declare target
int a1;
void f1() {
}
#pragma omp declare target (a1, f1)
// CHECK: #pragma omp declare target{{$}}
// CHECK: int a1;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target{{$}}
// CHECK: void f1()
// CHECK: #pragma omp end declare target{{$}}
int b1, b2, b3;
void f2() {
}
#pragma omp declare target to(b1) to(b2), to(b3, f2)
// CHECK: #pragma omp declare target{{$}}
// CHECK: int b1;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target{{$}}
// CHECK: int b2;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target{{$}}
// CHECK: int b3;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target{{$}}
// CHECK: void f2()
// CHECK: #pragma omp end declare target{{$}}
int c1, c2, c3;
#pragma omp declare target link(c1) link(c2), link(c3)
// CHECK: #pragma omp declare target link{{$}}
// CHECK: int c1;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target link{{$}}
// CHECK: int c2;
// CHECK: #pragma omp end declare target{{$}}
// CHECK: #pragma omp declare target link{{$}}
// CHECK: int c3;
// CHECK: #pragma omp end declare target{{$}}
struct SSSt {
#pragma omp declare target
static int a;
int b;
#pragma omp end declare target
};
// CHECK: struct SSSt {
// CHECK: #pragma omp declare target
// CHECK: static int a;
// CHECK: #pragma omp end declare target
// CHECK: int b;
template <class T>
struct SSSTt {
#pragma omp declare target
static T a;
int b;
#pragma omp end declare target
};
// CHECK: template <class T> struct SSSTt {
// CHECK: #pragma omp declare target
// CHECK: static T a;
// CHECK: #pragma omp end declare target
// CHECK: int b;
#pragma omp declare target
template <typename T>
T baz() { return T(); }
#pragma omp end declare target
template <>
int baz() { return 1; }
// CHECK: #pragma omp declare target
// CHECK: template <typename T> T baz() {
// CHECK: return T();
// CHECK: }
// CHECK: #pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: template<> float baz<float>() {
// CHECK: return float();
// CHECK: }
// CHECK: template<> int baz<int>() {
// CHECK: return 1;
// CHECK: }
// CHECK: #pragma omp end declare target
#pragma omp declare target
#include "declare_target_include.h"
void xyz();
#pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: void zyx();
// CHECK: #pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: void xyz();
// CHECK: #pragma omp end declare target
#pragma omp declare target
#pragma omp declare target
void abc();
#pragma omp end declare target
void cba();
#pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: void abc();
// CHECK: #pragma omp end declare target
// CHECK: #pragma omp declare target
// CHECK: void cba();
// CHECK: #pragma omp end declare target
#pragma omp declare target
int abc1() { return 1; }
#pragma omp declare target to(abc1) device_type(nohost)
#pragma omp end declare target
// CHECK-NEXT: #pragma omp declare target
// CHECK-NEXT: #pragma omp declare target device_type(nohost)
// CHECK-NEXT: int abc1() {
// CHECK-NEXT: return 1;
// CHECK-NEXT: }
// CHECK-NEXT: #pragma omp end declare target
#pragma omp declare target
int inner_link;
#pragma omp declare target link(inner_link)
#pragma omp end declare target
// CHECK-NEXT: #pragma omp declare target
// CHECK-NEXT: #pragma omp declare target link
// CHECK-NEXT: int inner_link;
// CHECK-NEXT: #pragma omp end declare target
int main (int argc, char **argv) {
foo();
foo_c();
foo_cpp();
test1();
baz<float>();
baz<int>();
return (0);
}
// CHECK: #pragma omp declare target
// CHECK-NEXT: int ts = 1;
// CHECK-NEXT: #pragma omp end declare target
// Do not expect anything here since the region is empty.
#pragma omp declare target
#pragma omp end declare target
#endif
|