Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 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); |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 16 | // CHECK-LABEL: define %struct.A* @_Z6upcastP1B |
Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 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); |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 24 | // CHECK-LABEL: define %struct.B* @_Z8samecastP1B |
Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 25 | // CHECK-NOT: call i8* @__dynamic_cast |
| 26 | } |