Hans Wennborg | c9bd88e | 2014-01-14 19:35:09 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -verify -fno-rtti -triple %itanium_abi_triple -o - | FileCheck %s |
Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 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); |
David Blaikie | ea3e51d | 2015-06-29 17:29:50 +0000 | [diff] [blame] | 16 | // CHECK-LABEL: define {{.*}}%struct.A* @_Z6upcastP1B |
| 17 | // CHECK-NOT: call {{.*}}i8* @__dynamic_cast |
Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 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); |
David Blaikie | ea3e51d | 2015-06-29 17:29:50 +0000 | [diff] [blame] | 24 | // CHECK-LABEL: define {{.*}}%struct.B* @_Z8samecastP1B |
| 25 | // CHECK-NOT: call {{.*}}i8* @__dynamic_cast |
Arnaud A. de Grandmaison | cb6f943 | 2013-08-01 08:28:32 +0000 | [diff] [blame] | 26 | } |