[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / no-rtti-data.cpp
blobaf0dc7c11bb811257481bc3768b792322713ad2c
1 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux -fno-rtti-data -fsyntax-only -verify
3 namespace std {
4 struct type_info {};
5 } // namespace std
6 class B {
7 public:
8 virtual ~B() = default;
9 };
11 class D1 : public B {
12 public:
13 ~D1() = default;
16 void 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 -fno-rtti-data}}
19 void *v = dynamic_cast<void *>(b);
21 (void)typeid(int);
22 (void)typeid(b);
23 (void)typeid(*b); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
24 B b2 = *b;
25 (void)typeid(b2);
26 (void)typeid(*&b2); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
27 (void)typeid((B &)b2);
29 B &br = b2;
30 (void)typeid(br); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
31 (void)typeid(&br);