teak-llvm/clang/test/Parser/cuda-force-host-device.cu
Justin Lebar 67a78a6cc0 [CUDA] Add #pragma clang force_cuda_host_device_{begin,end} pragmas.
Summary:
These cause us to consider all functions in-between to be __host__
__device__.

You can nest these pragmas; you just can't have more 'end's than
'begin's.

Reviewers: rsmith

Subscribers: tra, jhen, cfe-commits

Differential Revision: https://reviews.llvm.org/D24975

llvm-svn: 283677
2016-10-08 22:15:58 +00:00

37 lines
891 B
Plaintext

// RUN: %clang_cc1 -fsyntax-only -verify %s
// Check the force_cuda_host_device pragma.
#pragma clang force_cuda_host_device begin
void f();
#pragma clang force_cuda_host_device begin
void g();
#pragma clang force_cuda_host_device end
void h();
#pragma clang force_cuda_host_device end
void i(); // expected-note {{not viable}}
void host() {
f();
g();
h();
i();
}
__attribute__((device)) void device() {
f();
g();
h();
i(); // expected-error {{no matching function}}
}
#pragma clang force_cuda_host_device foo
// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}
#pragma clang force_cuda_host_device
// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}
#pragma clang force_cuda_host_device begin foo
// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}