| 1 |
// RUN: cir-opt %s -verify-diagnostics -split-input-file |
| 2 |
|
| 3 |
!s64i = !cir.int<s, 64> |
| 4 |
!s8i = !cir.int<s, 8> |
| 5 |
!u32i = !cir.int<u, 32> |
| 6 |
!u8i = !cir.int<u, 8> |
| 7 |
!void = !cir.void |
| 8 |
|
| 9 |
!Base = !cir.record<struct "Base" {!cir.ptr<!cir.ptr<!cir.func<() -> !cir.int<u, 32>>>>}> |
| 10 |
!Derived = !cir.record<struct "Derived" {!cir.record<struct "Base" {!cir.ptr<!cir.ptr<!cir.func<() -> !cir.int<u, 32>>>>}>}> |
| 11 |
|
| 12 |
module { |
| 13 |
cir.global "private" constant external @_ZTI4Base : !cir.ptr<!u32i> |
| 14 |
cir.global "private" constant external @_ZTI7Derived : !cir.ptr<!u8i> |
| 15 |
cir.func private @__dynamic_cast(!cir.ptr<!void>, !cir.ptr<!u8i>, !cir.ptr<!u8i>, !s64i) -> !cir.ptr<!void> |
| 16 |
cir.func private @__cxa_bad_cast() |
| 17 |
cir.func @test(%arg0 : !cir.ptr<!Base>) { |
| 18 |
// expected-error@+1 {{srcRtti must be an RTTI pointer}} |
| 19 |
%0 = cir.dyn_cast ptr %arg0 : !cir.ptr<!Base> -> !cir.ptr<!Derived> #cir.dyn_cast_info<src_rtti = #cir.global_view<@_ZTI4Base> : !cir.ptr<!u32i>, dest_rtti = #cir.global_view<@_ZTI7Derived> : !cir.ptr<!u8i>, runtime_func = @__dynamic_cast, bad_cast_func = @__cxa_bad_cast, offset_hint = #cir.int<0> : !s64i> |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
// ----- |
| 24 |
|
| 25 |
!s64i = !cir.int<s, 64> |
| 26 |
!s8i = !cir.int<s, 8> |
| 27 |
!u32i = !cir.int<u, 32> |
| 28 |
!u8i = !cir.int<u, 8> |
| 29 |
!void = !cir.void |
| 30 |
|
| 31 |
!Base = !cir.record<struct "Base" {!cir.ptr<!cir.ptr<!cir.func<() -> !cir.int<u, 32>>>>}> |
| 32 |
!Derived = !cir.record<struct "Derived" {!cir.record<struct "Base" {!cir.ptr<!cir.ptr<!cir.func<() -> !cir.int<u, 32>>>>}>}> |
| 33 |
|
| 34 |
module { |
| 35 |
cir.global "private" constant external @_ZTI4Base : !cir.ptr<!u8i> |
| 36 |
cir.global "private" constant external @_ZTI7Derived : !cir.ptr<!u32i> |
| 37 |
cir.func private @__dynamic_cast(!cir.ptr<!void>, !cir.ptr<!u8i>, !cir.ptr<!u8i>, !s64i) -> !cir.ptr<!void> |
| 38 |
cir.func private @__cxa_bad_cast() |
| 39 |
cir.func @test(%arg0 : !cir.ptr<!Base>) { |
| 40 |
// expected-error@+1 {{destRtti must be an RTTI pointer}} |
| 41 |
%0 = cir.dyn_cast ptr %arg0 : !cir.ptr<!Base> -> !cir.ptr<!Derived> #cir.dyn_cast_info<src_rtti = #cir.global_view<@_ZTI4Base> : !cir.ptr<!u8i>, dest_rtti = #cir.global_view<@_ZTI7Derived> : !cir.ptr<!u32i>, runtime_func = @__dynamic_cast, bad_cast_func = @__cxa_bad_cast, offset_hint = #cir.int<0> : !s64i> |
| 42 |
} |
| 43 |
} |