diff options
Diffstat (limited to 'test/support/test.support/test_macros_header_rtti.fail.cpp')
| -rw-r--r-- | test/support/test.support/test_macros_header_rtti.fail.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/support/test.support/test_macros_header_rtti.fail.cpp b/test/support/test.support/test_macros_header_rtti.fail.cpp new file mode 100644 index 000000000000..851a6c601416 --- /dev/null +++ b/test/support/test.support/test_macros_header_rtti.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 +} |
