2012-05-20 09:27:21 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -fno-rtti %s
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
class type_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f()
|
|
|
|
{
|
2018-06-07 08:42:59 +08:00
|
|
|
(void)typeid(int); // expected-error {{use of typeid requires -frtti}}
|
2012-05-20 09:27:21 +08:00
|
|
|
}
|
2013-08-01 16:28:32 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
struct A {
|
|
|
|
virtual ~A(){};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : public A {
|
|
|
|
B() : A() {}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isa_B(A *a) {
|
2018-06-07 08:42:59 +08:00
|
|
|
return dynamic_cast<B *>(a) != 0; // expected-error {{use of dynamic_cast requires -frtti}}
|
2013-08-01 16:28:32 +08:00
|
|
|
}
|
2013-09-25 07:21:41 +08:00
|
|
|
|
|
|
|
void* getMostDerived(A* a) {
|
|
|
|
// This cast does not use RTTI.
|
|
|
|
return dynamic_cast<void *>(a);
|
|
|
|
}
|