1 // RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -fsyntax-only -std=c++17 -verify %s
3 #include "Inputs/cuda.h"
5 // Error, instantiated on device.
6 inline __host__ __device__ void hasInvalid() {
8 // expected-error@-1 2{{cannot use 'throw' in __host__ __device__ function}}
11 inline __host__ __device__ void hasInvalid2() {
13 // expected-error@-1 2{{cannot use 'throw' in __host__ __device__ function}}
16 inline __host__ __device__ void hasInvalidDiscarded() {
17 // This is only used in the discarded statements below, so this should not diagnose.
21 static __device__ void use0() {
22 hasInvalid(); // expected-note {{called by 'use0'}}
23 hasInvalid(); // expected-note {{called by 'use0'}}
26 hasInvalid2(); // expected-note {{called by 'use0'}}
28 hasInvalidDiscarded();
31 if constexpr (false) {
32 hasInvalidDiscarded();
34 hasInvalid2(); // expected-note {{called by 'use0'}}
37 if constexpr (false) {
38 hasInvalidDiscarded();
42 // To avoid excessive diagnostic messages, deferred diagnostics are only
43 // emitted the first time a function is called.
44 static __device__ void use1() {
45 use0(); // expected-note 4{{called by 'use1'}}
49 static __device__ void use2() {
50 use1(); // expected-note 4{{called by 'use2'}}
54 static __device__ void use3() {
55 use2(); // expected-note 4{{called by 'use3'}}
59 __global__ void use4() {
60 use3(); // expected-note 4{{called by 'use4'}}