1 // RUN: %clang_cc1 -fsyntax-only -verify=host,expected %s
2 // RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify=dev,expected %s
4 #include "Inputs/cuda.h"
6 //------------------------------------------------------------------------------
7 // Test 1: host method called from device function
10 void method() {} // dev-note {{'method' declared here}}
13 __device__ void foo1(S1& s) {
14 s.method(); // dev-error {{reference to __host__ function 'method' in __device__ function}}
17 //------------------------------------------------------------------------------
18 // Test 2: host method called from device function, for overloaded method
21 void method(int) {} // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
22 void method(float) {} // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
25 __device__ void foo2(S2& s, int i, float f) {
26 s.method(f); // expected-error {{no matching member function}}
29 //------------------------------------------------------------------------------
30 // Test 3: device method called from host function
33 __device__ void method() {} // host-note {{'method' declared here}}
37 s.method(); // host-error {{reference to __device__ function 'method' in __host__ function}}
40 //------------------------------------------------------------------------------
41 // Test 4: device method called from host&device function
44 __device__ void method() {} // host-note {{'method' declared here}}
47 __host__ __device__ void foo4(S4& s) {
48 s.method(); // host-error {{reference to __device__ function 'method' in __host__ __device__ function}}
51 //------------------------------------------------------------------------------
52 // Test 5: overloaded operators
56 S5& operator=(const S5&) {return *this;} // expected-note {{candidate function not viable}}
59 __device__ void foo5(S5& s, S5& t) {
60 s = t; // expected-error {{no viable overloaded '='}}
63 //------------------------------------------------------------------------------
64 // Test 6: call method through pointer
67 void method() {} // dev-note {{'method' declared here}};
70 __device__ void foo6(S6* s) {
71 s->method(); // dev-error {{reference to __host__ function 'method' in __device__ function}}