llvm-project
33 строки · 933.0 Байт
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
10struct A {
11A(); // dev-note 2{{'A' declared here}}
12};
13
14template <class T, int x> struct B {
15T a;
16constexpr B() = default; // dev-error 2{{reference to __host__ function 'A' in __host__ __device__ function}}
17};
18
19__host__ void f() { B<A, 1> x; }
20__device__ void f() { B<A, 1> x; } // dev-note{{called by 'f'}}
21
22struct foo {
23__host__ foo() { B<A, 2> x; }
24__device__ foo() { B<A, 2> x; } // dev-note{{called by 'foo'}}
25};
26
27__host__ void g() { foo x; }
28__device__ void g() { foo x; } // dev-note{{called by 'g'}}
29
30struct bar {
31__host__ bar() { B<A, 3> x; }
32__device__ bar() { B<A, 3> x; } // no error since no instantiation of bar
33};
34