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 
4 struct CopyableH {
operator =CopyableH5   const CopyableH& operator=(const CopyableH& x) { return *this; }
6 };
7 struct CopyableD {
operator =CopyableD8   __attribute__((device)) const CopyableD& operator=(const CopyableD x) { return *this; }
9 };
10 
11 struct SimpleH {
12   CopyableH b;
13 };
14 // expected-note@-3 2 {{candidate function (the implicit copy assignment operator) not viable: call to __host__ function from __device__ function}}
15 // expected-note@-4 2 {{candidate function (the implicit move assignment operator) not viable: call to __host__ function from __device__ function}}
16 
17 struct SimpleD {
18   CopyableD b;
19 };
20 // expected-note@-3 2 {{candidate function (the implicit copy assignment operator) not viable: call to __device__ function from __host__ function}}
21 // expected-note@-4 2 {{candidate function (the implicit move assignment operator) not viable: call to __device__ function from __host__ function}}
22 
foo1hh()23 void foo1hh() {
24   SimpleH a, b;
25   a = b;
26 }
foo1hd()27 __attribute__((device)) void foo1hd() {
28   SimpleH a, b;
29   a = b; // expected-error {{no viable overloaded}}
30 }
foo1dh()31 void foo1dh() {
32   SimpleD a, b;
33   a = b; // expected-error {{no viable overloaded}}
34 }
foo1dd()35 __attribute__((device)) void foo1dd() {
36   SimpleD a, b;
37   a = b;
38 }
39 
foo2hh(SimpleH & a,SimpleH & b)40 void foo2hh(SimpleH &a, SimpleH &b) {
41   a = b;
42 }
foo2hd(SimpleH & a,SimpleH & b)43 __attribute__((device)) void foo2hd(SimpleH &a, SimpleH &b) {
44   a = b; // expected-error {{no viable overloaded}}
45 }
foo2dh(SimpleD & a,SimpleD & b)46 void foo2dh(SimpleD &a, SimpleD &b) {
47   a = b; // expected-error {{no viable overloaded}}
48 }
foo2dd(SimpleD & a,SimpleD & b)49 __attribute__((device)) void foo2dd(SimpleD &a, SimpleD &b) {
50   a = b;
51 }
52