================
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify=expected,dev %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x hip -fcuda-is-device -fsyntax-only -verify=expected,dev 
%s
+// RUN: %clang_cc1 -x hip -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+namespace std {
+class type_info {};
+} // namespace std
+
+struct B {
+  __host__ __device__ virtual ~B() {}
+};
+struct D : B {};
+
+void host(B *b) {
+  (void)dynamic_cast<D *>(b);
+  (void)typeid(*b);
+}
+
+__device__ void device(B *b, D *d) {
+  (void)dynamic_cast<D *>(b);
+  // expected-error@-1 {{cannot use 'dynamic_cast' in __device__ function as 
RTTI is not available in device code}}
+  (void)dynamic_cast<D &>(*b);
+  // expected-error@-1 {{cannot use 'dynamic_cast' in __device__ function as 
RTTI is not available in device code}}
+  (void)typeid(D);
+  // expected-error@-1 {{cannot use 'typeid' in __device__ function as RTTI is 
not available in device code}}
+  (void)typeid(*b);
+  // expected-error@-1 {{cannot use 'typeid' in __device__ function as RTTI is 
not available in device code}}
+  (void)sizeof(typeid(int));
+  // expected-error@-1 {{cannot use 'typeid' in __device__ function as RTTI is 
not available in device code}}
+
+  // As with -fno-rtti, these don't use RTTI and are allowed.
+  (void)dynamic_cast<void *>(b);
+  (void)dynamic_cast<B *>(d);
+}
+
+__global__ void kernel(B *b) {
+  (void)typeid(*b);
+  // expected-error@-1 {{cannot use 'typeid' in __global__ function as RTTI is 
not available in device code}}
----------------
steffenlarsen wrote:

Added!

https://github.com/llvm/llvm-project/pull/228469
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to