mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-12 09:41:26 +00:00
Allow dynamic_cast to void* even with -fno-rtti.
PR17346. llvm-svn: 191340
This commit is contained in:
parent
1f5d8882f9
commit
3ce27103d9
@ -669,8 +669,10 @@ void CastOperation::CheckDynamicCast() {
|
||||
Self.MarkVTableUsed(OpRange.getBegin(),
|
||||
cast<CXXRecordDecl>(SrcRecord->getDecl()));
|
||||
|
||||
// dynamic_cast is not available with fno-rtti
|
||||
if (!Self.getLangOpts().RTTI) {
|
||||
// dynamic_cast is not available with -fno-rtti.
|
||||
// As an exception, dynamic_cast to void* is available because it doesn't
|
||||
// use RTTI.
|
||||
if (!Self.getLangOpts().RTTI && !DestPointee->isVoidType()) {
|
||||
Self.Diag(OpRange.getBegin(), diag::err_no_dynamic_cast_with_fno_rtti);
|
||||
SrcExpr = ExprError();
|
||||
return;
|
||||
|
@ -22,3 +22,8 @@ struct B : public A {
|
||||
bool isa_B(A *a) {
|
||||
return dynamic_cast<B *>(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}}
|
||||
}
|
||||
|
||||
void* getMostDerived(A* a) {
|
||||
// This cast does not use RTTI.
|
||||
return dynamic_cast<void *>(a);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user