xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/no-rtti.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -fno-rtti %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc namespace std {
4*f4a2713aSLionel Sambuc   class type_info;
5*f4a2713aSLionel Sambuc }
6*f4a2713aSLionel Sambuc 
f()7*f4a2713aSLionel Sambuc void f()
8*f4a2713aSLionel Sambuc {
9*f4a2713aSLionel Sambuc   (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc namespace {
13*f4a2713aSLionel Sambuc struct A {
~A__anon8313d02b0111::A14*f4a2713aSLionel Sambuc   virtual ~A(){};
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc struct B : public A {
B__anon8313d02b0111::B18*f4a2713aSLionel Sambuc   B() : A() {}
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc 
isa_B(A * a)22*f4a2713aSLionel Sambuc bool isa_B(A *a) {
23*f4a2713aSLionel Sambuc   return dynamic_cast<B *>(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}}
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
getMostDerived(A * a)26*f4a2713aSLionel Sambuc void* getMostDerived(A* a) {
27*f4a2713aSLionel Sambuc   // This cast does not use RTTI.
28*f4a2713aSLionel Sambuc   return dynamic_cast<void *>(a);
29*f4a2713aSLionel Sambuc }
30