You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libcxx/test/support/test.support/test_macros_header_rtti.fai...

30 lines
756 B
C++

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// "support/test_macros.hpp"
// #define TEST_HAS_NO_RTTI
#include "test_macros.h"
struct A { virtual ~A() {} };
struct B : A {};
int main() {
#if defined(TEST_HAS_NO_RTTI)
A* ptr = new B;
(void)dynamic_cast<B*>(ptr); // expected-error{{cannot use dynamic_cast}}
#else
A* ptr = new B;
(void)dynamic_cast<B*>(ptr);
#error RTTI enabled
// expected-error@-1{{RTTI enabled}}
#endif
}