diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-22 05:29:15 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-22 05:29:15 +0000 |
commit | 88d38802e27244bb6fc074d4e981d3df42be61c1 (patch) | |
tree | 9070b95337723a3e43cb2eef8eead40aa416c763 /libcxx/test/support | |
parent | eb067d4ebda813c47cd85c3953327330f0fb5d72 (diff) | |
download | bcm5719-llvm-88d38802e27244bb6fc074d4e981d3df42be61c1.tar.gz bcm5719-llvm-88d38802e27244bb6fc074d4e981d3df42be61c1.zip |
Add tests for RTTI/exceptions test macros.
llvm-svn: 273382
Diffstat (limited to 'libcxx/test/support')
-rw-r--r-- | libcxx/test/support/test.support/test_convertible_header.pass.cpp (renamed from libcxx/test/support/test_convertible_header.pass.cpp) | 0 | ||||
-rw-r--r-- | libcxx/test/support/test.support/test_macros_header_exceptions.fail.cpp | 24 | ||||
-rw-r--r-- | libcxx/test/support/test.support/test_macros_header_exceptions.pass.cpp | 24 | ||||
-rw-r--r-- | libcxx/test/support/test.support/test_macros_header_rtti.fail.cpp | 29 | ||||
-rw-r--r-- | libcxx/test/support/test.support/test_macros_header_rtti.pass.cpp | 28 |
5 files changed, 105 insertions, 0 deletions
diff --git a/libcxx/test/support/test_convertible_header.pass.cpp b/libcxx/test/support/test.support/test_convertible_header.pass.cpp index a56b84b4739..a56b84b4739 100644 --- a/libcxx/test/support/test_convertible_header.pass.cpp +++ b/libcxx/test/support/test.support/test_convertible_header.pass.cpp diff --git a/libcxx/test/support/test.support/test_macros_header_exceptions.fail.cpp b/libcxx/test/support/test.support/test_macros_header_exceptions.fail.cpp new file mode 100644 index 00000000000..ade2cd98fe0 --- /dev/null +++ b/libcxx/test/support/test.support/test_macros_header_exceptions.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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_EXCEPTIONS + +#include "test_macros.h" + +int main() { +#if defined(TEST_HAS_NO_EXCEPTIONS) + try { ((void)0); } catch (...) {} // expected-error {{exceptions disabled}} +#else + try { ((void)0); } catch (...) {} +#error exceptions enabled +// expected-error@-1 {{exceptions enabled}} +#endif +} diff --git a/libcxx/test/support/test.support/test_macros_header_exceptions.pass.cpp b/libcxx/test/support/test.support/test_macros_header_exceptions.pass.cpp new file mode 100644 index 00000000000..589e148a003 --- /dev/null +++ b/libcxx/test/support/test.support/test_macros_header_exceptions.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: libcpp-no-exceptions + +// "support/test_macros.hpp" + +// #define TEST_HAS_NO_EXCEPTIONS + +#include "test_macros.h" + +#if defined(TEST_HAS_NO_EXCEPTIONS) +#error macro defined unexpectedly +#endif + +int main() { + try { ((void)0); } catch (...) {} +} diff --git a/libcxx/test/support/test.support/test_macros_header_rtti.fail.cpp b/libcxx/test/support/test.support/test_macros_header_rtti.fail.cpp new file mode 100644 index 00000000000..851a6c60141 --- /dev/null +++ b/libcxx/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 +} diff --git a/libcxx/test/support/test.support/test_macros_header_rtti.pass.cpp b/libcxx/test/support/test.support/test_macros_header_rtti.pass.cpp new file mode 100644 index 00000000000..d189a0efc2f --- /dev/null +++ b/libcxx/test/support/test.support/test_macros_header_rtti.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: libcpp-no-rtti + +// "support/test_macros.hpp" + +// #define TEST_HAS_NO_RTTI + +#include "test_macros.h" + +#if defined(TEST_HAS_NO_RTTI) +#error Macro defined unexpectedly +#endif + +struct A { virtual ~A() {} }; +struct B : A {}; + +int main() { + A* ptr = new B; + (void)dynamic_cast<B*>(ptr); +} |