32 lines · cpp
1// RUN: %clang_cc1 %s -triple x86_64-windows-msvc -fdiagnostics-format msvc -fno-rtti-data -fsyntax-only -verify2 3namespace std {4struct type_info {};5} // namespace std6class B {7public:8 virtual ~B() = default;9};10 11class D1 : public B {12public:13 ~D1() = default;14};15 16void f() {17 B *b = new D1();18 auto d = dynamic_cast<D1 *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}19 void *v = dynamic_cast<void *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}20 21 (void)typeid(int);22 (void)typeid(b);23 (void)typeid(*b); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}24 B b2 = *b;25 (void)typeid(b2);26 (void)typeid(*&b2); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}27 (void)typeid((B &)b2);28 29 B &br = b2;30 (void)typeid(br); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}31 (void)typeid(&br);32}