implicit-copy.cu 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fcuda-is-device -fsyntax-only -verify %s
  3. struct CopyableH {
  4. const CopyableH& operator=(const CopyableH& x) { return *this; }
  5. };
  6. struct CopyableD {
  7. __attribute__((device)) const CopyableD& operator=(const CopyableD x) { return *this; }
  8. };
  9. struct SimpleH {
  10. CopyableH b;
  11. };
  12. // expected-note@-3 2 {{candidate function (the implicit copy assignment operator) not viable: call to __host__ function from __device__ function}}
  13. // expected-note@-4 2 {{candidate function (the implicit move assignment operator) not viable: call to __host__ function from __device__ function}}
  14. struct SimpleD {
  15. CopyableD b;
  16. };
  17. // expected-note@-3 2 {{candidate function (the implicit copy assignment operator) not viable: call to __device__ function from __host__ function}}
  18. // expected-note@-4 2 {{candidate function (the implicit move assignment operator) not viable: call to __device__ function from __host__ function}}
  19. void foo1hh() {
  20. SimpleH a, b;
  21. a = b;
  22. }
  23. __attribute__((device)) void foo1hd() {
  24. SimpleH a, b;
  25. a = b; // expected-error {{no viable overloaded}}
  26. }
  27. void foo1dh() {
  28. SimpleD a, b;
  29. a = b; // expected-error {{no viable overloaded}}
  30. }
  31. __attribute__((device)) void foo1dd() {
  32. SimpleD a, b;
  33. a = b;
  34. }
  35. void foo2hh(SimpleH &a, SimpleH &b) {
  36. a = b;
  37. }
  38. __attribute__((device)) void foo2hd(SimpleH &a, SimpleH &b) {
  39. a = b; // expected-error {{no viable overloaded}}
  40. }
  41. void foo2dh(SimpleD &a, SimpleD &b) {
  42. a = b; // expected-error {{no viable overloaded}}
  43. }
  44. __attribute__((device)) void foo2dd(SimpleD &a, SimpleD &b) {
  45. a = b;
  46. }