reference-to-kernel-fn.cu 815 B

1234567891011121314151617181920212223242526272829
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify \
  2. // RUN: -verify-ignore-unexpected=note %s
  3. // RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify \
  4. // RUN: -verify-ignore-unexpected=note -DDEVICE %s
  5. // Check that we can reference (get a function pointer to) a __global__
  6. // function from the host side, but not the device side. (We don't yet support
  7. // device-side kernel launches.)
  8. #include "Inputs/cuda.h"
  9. struct Dummy {};
  10. __global__ void kernel() {}
  11. typedef void (*fn_ptr_t)();
  12. __host__ __device__ fn_ptr_t get_ptr_hd() {
  13. return kernel;
  14. #ifdef DEVICE
  15. // expected-error@-2 {{reference to __global__ function}}
  16. #endif
  17. }
  18. __host__ fn_ptr_t get_ptr_h() {
  19. return kernel;
  20. }
  21. __device__ fn_ptr_t get_ptr_d() {
  22. return kernel; // expected-error {{reference to __global__ function}}
  23. }