| 1 | // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -fcuda-is-device %s |
| 2 | |
| 3 | // Check how the force_cuda_host_device pragma interacts with template |
| 4 | // instantiations. |
| 5 | |
| 6 | template <typename T> |
| 7 | auto foo() { // expected-note {{declared here}} |
| 8 | return T(); |
| 9 | } |
| 10 | |
| 11 | template <typename T> |
| 12 | struct X { |
| 13 | void foo(); // expected-note {{declared here}} |
| 14 | }; |
| 15 | |
| 16 | #pragma clang force_cuda_host_device begin |
| 17 | __attribute__((host)) __attribute__((device)) void test() { |
| 18 | int n = foo<int>(); // expected-error {{reference to __host__ function 'foo<int>'}} |
| 19 | X<int>().foo(); // expected-error {{reference to __host__ function 'foo'}} |
| 20 | } |
| 21 | #pragma clang force_cuda_host_device end |
| 22 | |
| 23 | // Same thing as above, but within a force_cuda_host_device block without a |
| 24 | // corresponding end. |
| 25 | |
| 26 | template <typename T> |
| 27 | T bar() { // expected-note {{declared here}} |
| 28 | return T(); |
| 29 | } |
| 30 | |
| 31 | template <typename T> |
| 32 | struct Y { |
| 33 | void bar(); // expected-note {{declared here}} |
| 34 | }; |
| 35 | |
| 36 | #pragma clang force_cuda_host_device begin |
| 37 | __attribute__((host)) __attribute__((device)) void test2() { |
| 38 | int n = bar<int>(); // expected-error {{reference to __host__ function 'bar<int>'}} |
| 39 | Y<int>().bar(); // expected-error {{reference to __host__ function 'bar'}} |
| 40 | } |
| 41 | |