From 27e7fd18f1c337c409f2a567697b27bcd0c09f8b Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Wed, 7 Jul 2021 17:12:12 -0400 Subject: Support manually disabling exceptions Rename EIGEN_EXCEPTIONS to EIGEN_USE_EXCEPTIONS, and allow disabling exceptions with -DEIGEN_USE_EXCEPTIONS=0. --- test/ctorleak.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'test/ctorleak.cpp') diff --git a/test/ctorleak.cpp b/test/ctorleak.cpp index 73904176b..e76a4a7ba 100644 --- a/test/ctorleak.cpp +++ b/test/ctorleak.cpp @@ -10,7 +10,7 @@ struct Foo Foo() : dummy(0) { -#ifdef EIGEN_EXCEPTIONS +#if EIGEN_USE_EXCEPTIONS // TODO: Is this the correct way to handle this? if (Foo::object_count > Foo::object_limit) { std::cout << "\nThrow!\n"; throw Foo::Fail(); } #endif @@ -46,10 +46,7 @@ EIGEN_DECLARE_TEST(ctorleak) MatrixX r(rows, cols); Foo::object_limit = r.size()+internal::random(0, rows*cols - 2); std::cout << "object_limit =" << Foo::object_limit << std::endl; -#ifdef EIGEN_EXCEPTIONS - try - { -#endif + EIGEN_TRY { if(internal::random()) { std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n"; MatrixX m(rows, cols); @@ -58,11 +55,11 @@ EIGEN_DECLARE_TEST(ctorleak) std::cout << "\nMatrixX m(r);\n"; MatrixX m(r); } -#ifdef EIGEN_EXCEPTIONS +#if EIGEN_USE_EXCEPTIONS VERIFY(false); // not reached if exceptions are enabled - } - catch (const Foo::Fail&) { /* ignore */ } #endif + } + EIGEN_CATCH(const Foo::Fail&) { /* ignore */ } } VERIFY_IS_EQUAL(Index(0), Foo::object_count); -- cgit v1.2.3