Author: ericwf Date: Wed Jun 22 00:29:15 2016 New Revision: 273382 URL: http://llvm.org/viewvc/llvm-project?rev=273382&view=rev Log: Add tests for RTTI/exceptions test macros.
Added: libcxx/trunk/test/support/test.support/ libcxx/trunk/test/support/test.support/test_convertible_header.pass.cpp libcxx/trunk/test/support/test.support/test_macros_header_exceptions.fail.cpp libcxx/trunk/test/support/test.support/test_macros_header_exceptions.pass.cpp libcxx/trunk/test/support/test.support/test_macros_header_rtti.fail.cpp libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp Removed: libcxx/trunk/test/support/test_convertible_header.pass.cpp Added: libcxx/trunk/test/support/test.support/test_convertible_header.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_convertible_header.pass.cpp?rev=273382&view=auto ============================================================================== --- libcxx/trunk/test/support/test.support/test_convertible_header.pass.cpp (added) +++ libcxx/trunk/test/support/test.support/test_convertible_header.pass.cpp Wed Jun 22 00:29:15 2016 @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// "support/test_convertible.hpp" + +#include "test_convertible.hpp" + +struct ImplicitDefault { + ImplicitDefault() {} +}; +static_assert(test_convertible<ImplicitDefault>(), "Must be convertible"); + +struct ExplicitDefault { + explicit ExplicitDefault() {} +}; +static_assert(!test_convertible<ExplicitDefault>(), "Must not be convertible"); + +struct ImplicitInt { + ImplicitInt(int) {} +}; +static_assert(test_convertible<ImplicitInt, int>(), "Must be convertible"); + +struct ExplicitInt { + explicit ExplicitInt(int) {} +}; +static_assert(!test_convertible<ExplicitInt, int>(), "Must not be convertible"); + +struct ImplicitCopy { + ImplicitCopy(ImplicitCopy const&) {} +}; +static_assert(test_convertible<ImplicitCopy, ImplicitCopy>(), "Must be convertible"); + +struct ExplicitCopy { + explicit ExplicitCopy(ExplicitCopy const&) {} +}; +static_assert(!test_convertible<ExplicitCopy, ExplicitCopy>(), "Must not be convertible"); + +struct ImplicitMove { + ImplicitMove(ImplicitMove&&) {} +}; +static_assert(test_convertible<ImplicitMove, ImplicitMove>(), "Must be convertible"); + +struct ExplicitMove { + explicit ExplicitMove(ExplicitMove&&) {} +}; +static_assert(!test_convertible<ExplicitMove, ExplicitMove>(), "Must not be convertible"); + +struct ImplicitArgs { + ImplicitArgs(int, int, int) {} +}; +static_assert(test_convertible<ImplicitArgs, int, int, int>(), "Must be convertible"); + +struct ExplicitArgs { + explicit ExplicitArgs(int, int, int) {} +}; +static_assert(!test_convertible<ExplicitArgs, int, int, int>(), "Must not be convertible"); + +int main() { + // Nothing to do +} Added: libcxx/trunk/test/support/test.support/test_macros_header_exceptions.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_exceptions.fail.cpp?rev=273382&view=auto ============================================================================== --- libcxx/trunk/test/support/test.support/test_macros_header_exceptions.fail.cpp (added) +++ libcxx/trunk/test/support/test.support/test_macros_header_exceptions.fail.cpp Wed Jun 22 00:29:15 2016 @@ -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 +} Added: libcxx/trunk/test/support/test.support/test_macros_header_exceptions.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_exceptions.pass.cpp?rev=273382&view=auto ============================================================================== --- libcxx/trunk/test/support/test.support/test_macros_header_exceptions.pass.cpp (added) +++ libcxx/trunk/test/support/test.support/test_macros_header_exceptions.pass.cpp Wed Jun 22 00:29:15 2016 @@ -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 (...) {} +} Added: libcxx/trunk/test/support/test.support/test_macros_header_rtti.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_rtti.fail.cpp?rev=273382&view=auto ============================================================================== --- libcxx/trunk/test/support/test.support/test_macros_header_rtti.fail.cpp (added) +++ libcxx/trunk/test/support/test.support/test_macros_header_rtti.fail.cpp Wed Jun 22 00:29:15 2016 @@ -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 +} Added: libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp?rev=273382&view=auto ============================================================================== --- libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp (added) +++ libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp Wed Jun 22 00:29:15 2016 @@ -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); +} Removed: libcxx/trunk/test/support/test_convertible_header.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_convertible_header.pass.cpp?rev=273381&view=auto ============================================================================== --- libcxx/trunk/test/support/test_convertible_header.pass.cpp (original) +++ libcxx/trunk/test/support/test_convertible_header.pass.cpp (removed) @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++98, c++03 - -// "support/test_convertible.hpp" - -#include "test_convertible.hpp" - -struct ImplicitDefault { - ImplicitDefault() {} -}; -static_assert(test_convertible<ImplicitDefault>(), "Must be convertible"); - -struct ExplicitDefault { - explicit ExplicitDefault() {} -}; -static_assert(!test_convertible<ExplicitDefault>(), "Must not be convertible"); - -struct ImplicitInt { - ImplicitInt(int) {} -}; -static_assert(test_convertible<ImplicitInt, int>(), "Must be convertible"); - -struct ExplicitInt { - explicit ExplicitInt(int) {} -}; -static_assert(!test_convertible<ExplicitInt, int>(), "Must not be convertible"); - -struct ImplicitCopy { - ImplicitCopy(ImplicitCopy const&) {} -}; -static_assert(test_convertible<ImplicitCopy, ImplicitCopy>(), "Must be convertible"); - -struct ExplicitCopy { - explicit ExplicitCopy(ExplicitCopy const&) {} -}; -static_assert(!test_convertible<ExplicitCopy, ExplicitCopy>(), "Must not be convertible"); - -struct ImplicitMove { - ImplicitMove(ImplicitMove&&) {} -}; -static_assert(test_convertible<ImplicitMove, ImplicitMove>(), "Must be convertible"); - -struct ExplicitMove { - explicit ExplicitMove(ExplicitMove&&) {} -}; -static_assert(!test_convertible<ExplicitMove, ExplicitMove>(), "Must not be convertible"); - -struct ImplicitArgs { - ImplicitArgs(int, int, int) {} -}; -static_assert(test_convertible<ImplicitArgs, int, int, int>(), "Must be convertible"); - -struct ExplicitArgs { - explicit ExplicitArgs(int, int, int) {} -}; -static_assert(!test_convertible<ExplicitArgs, int, int, int>(), "Must not be convertible"); - -int main() { - // Nothing to do -} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits