Mercurial > hg > CbC > CbC_llvm
comparison clang/test/SemaCUDA/method-target.cu @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 1d019706d866 |
children |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
1 // RUN: %clang_cc1 -fsyntax-only -verify %s | 1 // RUN: %clang_cc1 -fsyntax-only -verify=host,expected %s |
2 // RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify=dev,expected %s | |
2 | 3 |
3 #include "Inputs/cuda.h" | 4 #include "Inputs/cuda.h" |
4 | 5 |
5 //------------------------------------------------------------------------------ | 6 //------------------------------------------------------------------------------ |
6 // Test 1: host method called from device function | 7 // Test 1: host method called from device function |
7 | 8 |
8 struct S1 { | 9 struct S1 { |
9 void method() {} // expected-note {{'method' declared here}} | 10 void method() {} // dev-note {{'method' declared here}} |
10 }; | 11 }; |
11 | 12 |
12 __device__ void foo1(S1& s) { | 13 __device__ void foo1(S1& s) { |
13 s.method(); // expected-error {{reference to __host__ function 'method' in __device__ function}} | 14 s.method(); // dev-error {{reference to __host__ function 'method' in __device__ function}} |
14 } | 15 } |
15 | 16 |
16 //------------------------------------------------------------------------------ | 17 //------------------------------------------------------------------------------ |
17 // Test 2: host method called from device function, for overloaded method | 18 // Test 2: host method called from device function, for overloaded method |
18 | 19 |
27 | 28 |
28 //------------------------------------------------------------------------------ | 29 //------------------------------------------------------------------------------ |
29 // Test 3: device method called from host function | 30 // Test 3: device method called from host function |
30 | 31 |
31 struct S3 { | 32 struct S3 { |
32 __device__ void method() {} // expected-note {{'method' declared here}} | 33 __device__ void method() {} // host-note {{'method' declared here}} |
33 }; | 34 }; |
34 | 35 |
35 void foo3(S3& s) { | 36 void foo3(S3& s) { |
36 s.method(); // expected-error {{reference to __device__ function 'method' in __host__ function}} | 37 s.method(); // host-error {{reference to __device__ function 'method' in __host__ function}} |
37 } | 38 } |
38 | 39 |
39 //------------------------------------------------------------------------------ | 40 //------------------------------------------------------------------------------ |
40 // Test 4: device method called from host&device function | 41 // Test 4: device method called from host&device function |
41 | 42 |
42 struct S4 { | 43 struct S4 { |
43 __device__ void method() {} // expected-note {{'method' declared here}} | 44 __device__ void method() {} // host-note {{'method' declared here}} |
44 }; | 45 }; |
45 | 46 |
46 __host__ __device__ void foo4(S4& s) { | 47 __host__ __device__ void foo4(S4& s) { |
47 s.method(); // expected-error {{reference to __device__ function 'method' in __host__ __device__ function}} | 48 s.method(); // host-error {{reference to __device__ function 'method' in __host__ __device__ function}} |
48 } | 49 } |
49 | 50 |
50 //------------------------------------------------------------------------------ | 51 //------------------------------------------------------------------------------ |
51 // Test 5: overloaded operators | 52 // Test 5: overloaded operators |
52 | 53 |
61 | 62 |
62 //------------------------------------------------------------------------------ | 63 //------------------------------------------------------------------------------ |
63 // Test 6: call method through pointer | 64 // Test 6: call method through pointer |
64 | 65 |
65 struct S6 { | 66 struct S6 { |
66 void method() {} // expected-note {{'method' declared here}}; | 67 void method() {} // dev-note {{'method' declared here}}; |
67 }; | 68 }; |
68 | 69 |
69 __device__ void foo6(S6* s) { | 70 __device__ void foo6(S6* s) { |
70 s->method(); // expected-error {{reference to __host__ function 'method' in __device__ function}} | 71 s->method(); // dev-error {{reference to __host__ function 'method' in __device__ function}} |
71 } | 72 } |