Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -emit-llvm %s -verify -fno-rtti -o - | FileCheck %s
      2 // expected-no-diagnostics
      3 
      4 struct A {
      5   virtual ~A(){};
      6 };
      7 
      8 struct B : public A {
      9   B() : A() {}
     10 };
     11 
     12 // An upcast can be resolved statically and can be used with -fno-rtti, iff it
     13 // does not use runtime support.
     14 A *upcast(B *b) {
     15   return dynamic_cast<A *>(b);
     16 // CHECK: define %struct.A* @_Z6upcastP1B
     17 // CHECK-NOT: call i8* @__dynamic_cast
     18 }
     19 
     20 // A NoOp dynamic_cast can be used with -fno-rtti iff it does not use
     21 // runtime support.
     22 B *samecast(B *b) {
     23   return dynamic_cast<B *>(b);
     24 // CHECK: define %struct.B* @_Z8samecastP1B
     25 // CHECK-NOT: call i8* @__dynamic_cast
     26 }
     27