1 // RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify %s
4 #include "Inputs/cuda.h"
10 __device__ void device() {
12 // expected-error@-1 {{cannot use 'throw' in __device__ function}}
13 try {} catch(void*) {}
14 // expected-error@-1 {{cannot use 'try' in __device__ function}}
16 __global__ void kernel() {
18 // expected-error@-1 {{cannot use 'throw' in __global__ function}}
19 try {} catch(void*) {}
20 // expected-error@-1 {{cannot use 'try' in __global__ function}}
23 // Check that it's an error to use 'try' and 'throw' from a __host__ __device__
24 // function if and only if it's codegen'ed for device.
26 __host__ __device__ void hd1() {
28 try {} catch(void*) {}
30 // expected-error@-3 {{cannot use 'throw' in __host__ __device__ function}}
31 // expected-error@-3 {{cannot use 'try' in __host__ __device__ function}}
35 // No error, never instantiated on device.
36 inline __host__ __device__ void hd2() {
38 try {} catch(void*) {}
40 void call_hd2() { hd2(); }
42 // Error, instantiated on device.
43 inline __host__ __device__ void hd3() {
45 try {} catch(void*) {}
47 // expected-error@-3 {{cannot use 'throw' in __host__ __device__ function}}
48 // expected-error@-3 {{cannot use 'try' in __host__ __device__ function}}
52 __device__ void call_hd3() { hd3(); }
54 // expected-note@-2 {{called by 'call_hd3'}}