1 // RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only \ 2 // RUN: -fcuda-is-device -verify=dev %s 3 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only \ 4 // RUN: -verify=host %s 5 6 // host-no-diagnostics 7 8 #include "Inputs/cuda.h" 9 10 struct A { 11 A(); // dev-note 2{{'A' declared here}} 12 }; 13 14 template <class T, int x> struct B { 15 T a; 16 constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' in __host__ __device__ function}} 17 }; 18 f()19__host__ void f() { B<A, 1> x; } f()20__device__ void f() { B<A, 1> x; } // dev-note{{called by 'f'}} 21 22 struct foo { foofoo23 __host__ foo() { B<A, 2> x; } foofoo24 __device__ foo() { B<A, 2> x; } // dev-note{{called by 'foo'}} 25 }; 26 g()27__host__ void g() { foo x; } g()28__device__ void g() { foo x; } // dev-note{{called by 'g'}} 29 30 struct bar { barbar31 __host__ bar() { B<A, 3> x; } barbar32 __device__ bar() { B<A, 3> x; } // no error since no instantiation of bar 33 }; 34