41 lines · plain
1// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -fcuda-is-device %s2 3// Check how the force_cuda_host_device pragma interacts with template4// instantiations.5 6template <typename T>7auto foo() { // expected-note {{declared here}}8 return T();9}10 11template <typename T>12struct X {13 void foo(); // expected-note {{declared here}}14};15 16#pragma clang force_cuda_host_device begin17__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 end22 23// Same thing as above, but within a force_cuda_host_device block without a24// corresponding end.25 26template <typename T>27T bar() { // expected-note {{declared here}}28 return T();29}30 31template <typename T>32struct Y {33 void bar(); // expected-note {{declared here}}34};35 36#pragma clang force_cuda_host_device begin37__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