function-target.cu 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
  3. #include "Inputs/cuda.h"
  4. __host__ void h1h(void);
  5. __device__ void h1d(void); // expected-note {{candidate function not viable: call to __device__ function from __host__ function}}
  6. __host__ __device__ void h1hd(void);
  7. __global__ void h1g(void);
  8. struct h1ds { // expected-note {{requires 1 argument}}
  9. __device__ h1ds(); // expected-note {{candidate constructor not viable: call to __device__ function from __host__ function}}
  10. };
  11. __host__ void h1(void) {
  12. h1h();
  13. h1d(); // expected-error {{no matching function}}
  14. h1hd();
  15. h1g<<<1, 1>>>();
  16. h1ds x; // expected-error {{no matching constructor}}
  17. }
  18. __host__ void d1h(void); // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
  19. __device__ void d1d(void);
  20. __host__ __device__ void d1hd(void);
  21. __global__ void d1g(void); // expected-note {{'d1g' declared here}}
  22. __device__ void d1(void) {
  23. d1h(); // expected-error {{no matching function}}
  24. d1d();
  25. d1hd();
  26. d1g<<<1, 1>>>(); // expected-error {{reference to __global__ function 'd1g' in __device__ function}}
  27. }