1 // RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
2 // RUN: -verify -verify-ignore-unexpected=note
4 // Note: This test won't work with -fsyntax-only, because some of these errors
5 // are emitted during codegen.
7 #include "Inputs/cuda.h"
9 __device__ void device_fn() {}
10 // expected-note@-1 5 {{'device_fn' declared here}}
14 // expected-note@-1 2 {{'S' declared here}}
15 __device__ ~S() { device_fn(); }
16 // expected-note@-1 {{'~S' declared here}}
21 __host__ __device__ void hd() { device_fn(); }
22 // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
24 // No error; this is (implicitly) inline and is never called, so isn't
26 __host__ __device__ void hd2() { device_fn(); }
28 __host__ __device__ void hd3();
30 __device__ void d() {}
31 // expected-note@-1 {{'d' declared here}}
34 __host__ __device__ void T::hd3() {
36 // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
39 template <typename T> __host__ __device__ void hd2() { device_fn(); }
40 // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
41 void host_fn() { hd2<int>(); }
43 __host__ __device__ void hd() { device_fn(); }
44 // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
46 // No error because this is never instantiated.
47 template <typename T> __host__ __device__ void hd3() { device_fn(); }
49 __host__ __device__ void local_var() {
51 // expected-error@-1 {{reference to __device__ function 'S' in __host__ __device__ function}}
54 __host__ __device__ void placement_new(char *ptr) {
56 // expected-error@-1 {{reference to __device__ function 'S' in __host__ __device__ function}}
59 __host__ __device__ void explicit_destructor(S *s) {
61 // expected-error@-1 {{reference to __device__ function '~S' in __host__ __device__ function}}
64 __host__ __device__ void hd_member_fn() {
66 // Necessary to trigger an error on T::hd. It's (implicitly) inline, so
67 // isn't codegen'ed until we call it.
71 __host__ __device__ void h_member_fn() {
74 // expected-error@-1 {{reference to __device__ function 'd' in __host__ __device__ function}}
77 __host__ __device__ void fn_ptr() {
78 auto* ptr = &device_fn;
79 // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
83 __host__ __device__ void fn_ptr_template() {
84 auto* ptr = &device_fn; // Not an error because the template isn't instantiated.