2022-10-06 12:12:57 +02:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -verify -fno-rtti -triple %itanium_abi_triple -o - | FileCheck %s
|
2013-08-01 08:28:32 +00:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual ~A(){};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : public A {
|
|
|
|
B() : A() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// An upcast can be resolved statically and can be used with -fno-rtti, iff it
|
|
|
|
// does not use runtime support.
|
|
|
|
A *upcast(B *b) {
|
|
|
|
return dynamic_cast<A *>(b);
|
2022-10-06 12:12:57 +02:00
|
|
|
// CHECK-LABEL: define {{.*}}ptr @_Z6upcastP1B
|
|
|
|
// CHECK-NOT: call {{.*}}ptr @__dynamic_cast
|
2013-08-01 08:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// A NoOp dynamic_cast can be used with -fno-rtti iff it does not use
|
|
|
|
// runtime support.
|
|
|
|
B *samecast(B *b) {
|
|
|
|
return dynamic_cast<B *>(b);
|
2022-10-06 12:12:57 +02:00
|
|
|
// CHECK-LABEL: define {{.*}}ptr @_Z8samecastP1B
|
|
|
|
// CHECK-NOT: call {{.*}}ptr @__dynamic_cast
|
2013-08-01 08:28:32 +00:00
|
|
|
}
|